QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#531103#6567. Repetitive String InventionAlicXWA 0ms3604kbC++141.1kb2024-08-24 18:22:562024-08-24 18:22:57

Judging History

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

  • [2024-08-24 18:22:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2024-08-24 18:22:56]
  • 提交

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; k <= n - (j - i); k++) {
				if (i >= k - j && s[j][k] == 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; 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';

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3604kb

input:

aaaa

output:

1

result:

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