QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#534709 | #7076. Browser Games | xiojoy# | WA | 0ms | 3660kb | C++20 | 2.1kb | 2024-08-27 15:30:28 | 2024-08-27 15:30:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define cctie ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(x) x.begin(), x.end()
#define ALL(x) x.begin() + 1, x.end()
using i64 = long long;
using i128 = __int128;
struct StringHash {
static constexpr int B = 131;
static constexpr array<int, 2> M = {1000000021, 1000000453};
array<vector<int>, 2> h, b;
StringHash(){}
StringHash(const string &s) { init(s); }
void init(const string &s) {
int n = s.size();
for (int j = 0; j < 2; j++) {
h[j].resize(n + 1), b[j].resize(n + 1, 1);
}
for (int j = 0; j < 2; j++) {
for (int i = 1; i <= n; i++) {
b[j][i] = 1LL * b[j][i - 1] * B % M[j];
h[j][i] = (1LL * h[j][i - 1] * B + s[i - 1]) % M[j];
}
}
}
array<int, 2> query(int l, int r) {
array<int, 2> val;
for (int j = 0; j < 2; j++) {
val[j] = (h[j][r] - 1LL * h[j][l - 1] * b[j][r - l + 1] % M[j] + M[j]) % M[j];
}
return val;
}
bool same(int l1, int r1, int l2, int r2) {
return query(l1, r1) == query(l2, r2);
}
};
void prework() {
}
int main() {
cctie;
prework();
int n;
cin >> n;
map<array<int, 2>, int> L, R;
vector<StringHash> SH(n + 1);
vector<string> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
SH[i].init(a[i]);
int m = a[i].size();
for (int j = 1; j <= m; j++) {
R[SH[i].query(1, j)]++;
}
}
int cur = 0;
for (int i = 1; i <= n; i++) {
int m = a[i].size();
for (int j = 1; j <= m; j++) {
R[SH[i].query(1, j)]--;
}
int ok = 1;
for (int j = 1; j <= m; j++) {
if (L[SH[i].query(1, j)] && !R[SH[i].query(1, j)]) {
ok = 0;
}
}
for (int j = 1; j <= m; j++) {
L[SH[i].query(1, j)]++;
}
cout << (cur += ok) << '\n';
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3572kb
input:
3 ufoipv.ofu hsbocmvfgboubtz.kq hfotijo.njipzp.dpn/kb
output:
1 2 2
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
3 hfotijo.njipzp.dpn/kb hsbocmvfgboubtz.kq ufoipv.ofu
output:
1 1 2
result:
ok 3 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
1 a
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
2 a b
output:
1 2
result:
ok 2 lines
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3628kb
input:
3 a.b/e a.c/e a.d/e
output:
1 2 2
result:
wrong answer 3rd lines differ - expected: '1', found: '2'