QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#408690#7076. Browser Gamesbright_mlWA 2ms6132kbC++201.3kb2024-05-10 21:24:202024-05-10 21:24:21

Judging History

你现在查看的是最新测评结果

  • [2024-05-10 21:24:21]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:6132kb
  • [2024-05-10 21:24:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 8e4 + 100;
int son[N*30][30],pre[N*30],tail[N*30],idx,sz[N*30],dp[N*30],fa[N*30],sum;
int n;
string s[N];
int f(char ch){
    if(ch >= 'a' && ch <= 'z') return ch - 'a';
    else if(ch == '.') return 26;
    else if(ch == '\\') return 27;
}
void insert1(string str) {
    int p = 0;
    for (int i = 0; i < str.size(); i++) {
        int u = f(str[i]);
        if (!son[p][u]) {
            son[p][u] = ++idx;
            fa[idx] = p;
        }
        p = son[p][u];
        tail[p]++;
    }
}
void insert2(string str) {
    int p = 0;
    for (int i = 0; i < str.size(); i++) {
        int u = f(str[i]);
        p = son[p][u];
        pre[p]++, tail[p]--;
    }
    while (true) {
        dp[p] = 0;
        if (1ll * pre[p] * tail[p]) {
            for (int i = 0; i <= 27; i++) {
                int u = son[p][i];
                if (!u) continue;
                dp[p] += dp[u];
                if (pre[u] != 0 && tail[u] == 0) dp[p]++;
            }
        }
        if (p == 0) break;
        p = fa[p];
    }
}
signed main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i=1;i<=n;i++) cin >> s[i],insert1(s[i]);
    for(int i=1;i<=n;i++){
        insert2(s[i]);
        cout << dp[0] << '\n';
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 6132kb

input:

3
ufoipv.ofu
hsbocmvfgboubtz.kq
hfotijo.njipzp.dpn/kb

output:

0
0
0

result:

wrong answer 1st lines differ - expected: '1', found: '0'