比赛 期末考试0 评测结果 AWEEEEEEEE
题目名称 学姐的下午茶 最终得分 10
用户昵称 对立猫猫对立 运行时间 1.203 s
代码语言 C++ 内存使用 4.08 MiB
提交时间 2026-02-07 09:53:54
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
struct trie {
    int nex[100000][2], cnt;
    bool exist[100000];
    void insert(char *s, int len, int step, int now) {
        if(step == len) {
            exist[now] = true;
            return;
        }
        if(s[step] == '?') {
            for(int i = 0; i <= 1; i++) {
                if(nex[now][i] == 0) {
                    nex[now][i] = ++cnt;
                }
                insert(s, len, step + 1, nex[now][i]);
            }
            return;
        }
        int u = s[step] - '0';
        if(nex[now][u] == 0) {
            nex[now][u] = ++cnt;
        }
        insert(s, len, step + 1, nex[now][u]);
        return;
    }
};
trie t;
char s[105];
int n;
int main() {
    freopen("lowtea.in", "r", stdin);
    freopen("lowtea.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> s;
        t.insert(s, strlen(s), 0, 0);
    }
    cout << t.cnt + 1 << "\n";
    return 0;
}