QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#408690 | #7076. Browser Games | bright_ml | WA | 2ms | 6132kb | C++20 | 1.3kb | 2024-05-10 21:24:20 | 2024-05-10 21:24:21 |
Judging History
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'