QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#531133 | #6567. Repetitive String Invention | AlicX | WA | 1ms | 3568kb | C++14 | 1.1kb | 2024-08-24 18:33:07 | 2024-08-24 18:33:07 |
Judging History
answer
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int SZ = 808;
const int MX = SZ * SZ;
int n, sz, trie[26][MX], s[SZ][SZ];
string S;
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
cin >> S;
n = S.size();
for (int i = 0; i < n; i++) {
int v = 0;
for (int j = i; j < n; j++) {
int c = S[j] - 'a';
if (!trie[c][v]) {
trie[c][v] = ++sz;
}
v = trie[c][v];
s[i][j] = v;
}
}
ll ans = 0;
for (int j = 0; j < n; j++) {
for (int i = 0; i < j; i++) {
int cnt = 0;
for (int k = j+1; k <= n - (j - i); k++) {
if (i >= k - j && s[j][k-1] == s[i - (k - j)][i-1]) {
++cnt;
}
if (s[i][j-1] == s[k][k + j - i-1]) {
ans += cnt;
}
}
cnt = 0;
for (int k = i-1; k >= j - i; k--) {
if (k != i && j + i - k <= n && s[k][i-1] == s[j][j + i - k-1]) {
++cnt;
}
if (s[k - (j - i)][k-1] == s[i][j-1]) {
ans += cnt;
}
}
}
}
cout << ans << '\n';
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3568kb
input:
aaaa
output:
2
result:
wrong answer 1st lines differ - expected: '9', found: '2'