QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#168311 | #7076. Browser Games | supepapupu# | WA | 2ms | 9088kb | C++17 | 1.4kb | 2023-09-08 09:02:36 | 2023-09-08 09:02:37 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define el '\n'
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 5e4 + 10, M = N * 50;
int tr[M][28], unrel[M], res[M], idx;
string str[N];
inline int get(char c) {
if ('a' <= c && 'z' >= c) return c - 'a';
return 26 + (c == '.');
}
void insert(int id) {
int p = 0;
for (char c: str[id]) {
++unrel[p];
int t = get(c);
if (!tr[p][t]) tr[p][t] = ++idx;
p = tr[p][t];
}
}
void change(int p, int id, int k) {
if (k == str[id].size()) {
res[p] = 1;
return;
}
--unrel[p];
int t = get(str[id][k]);
if (!unrel[p]) {
if (p) res[p] = 1;
else {
res[p] = 0;
for (int i = 0; i < 28; ++i)
if (tr[p][i]) ++res[p];
}
return;
}
change(tr[p][t], id, k + 1);
res[p] = 0;
for (int i = 0; i < 28; ++i)
if (tr[p][i]) {
res[p] += res[tr[p][i]];
}
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> str[i];
insert(i);
}
if (n == 1) {
cout << "0\n";
return 0;
}
for (int i = 1; i <= n; ++i) {
change(0, i, 0);
cout << res[0] << el;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 9088kb
input:
3 ufoipv.ofu hsbocmvfgboubtz.kq hfotijo.njipzp.dpn/kb
output:
1 2 2
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 8828kb
input:
3 hfotijo.njipzp.dpn/kb hsbocmvfgboubtz.kq ufoipv.ofu
output:
1 1 2
result:
ok 3 lines
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 8908kb
input:
1 a
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'