QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#91934#801. 回文自动机Yansuan_HCl#0 2ms7940kbC++14990b2023-03-29 22:36:012023-03-29 22:36:03

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-29 22:36:03]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:7940kb
  • [2023-03-29 22:36:01]
  • 提交

answer

#include <bits/stdc++.h>
#define ms(x, v) memset(x, v, sizeof(x))
#define il __attribute__((always_inline)) static
#define U(i,l,r) for(int i(l),END##i(r);i<=END##i;++i)
#define D(i,r,l) for(int i(r),END##i(l);i>=END##i;--i)
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
template <class T> using BS = basic_string<T>;

#define meow(...) fprintf(stderr, __VA_ARGS__)

const int N = 1000006;
char s[N]; int n, len[N], ch[N][26], fail[N], cnt[N], m;
ll ans;

int main() {
	scanf("%s", s + 1); n = strlen(s + 1);

	len[1] = -1; fail[0] = 1; m = 1; int p = 0;
	U (i, 1, n) {
		char c = s[i], d = s[i] - 'a';
		
		while (c != s[i - len[p] - 1]) p = fail[p];
		if (!ch[p][d]) {
			len[++m] = len[p] + 2;
			
			int j = p;
			while (c != s[i - len[j] - 1]) j = fail[j];
			fail[m] = ch[j][d];
			ch[p][d] = m;
		}
		p = ch[p][d];
		++cnt[p];
	}
	U (i, 1, m)
		ans = max(ans, ll(len[i]) * len[i] * cnt[i]);
	printf("%lld", ans);
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 7940kb

input:

bdgedcfadbabbfgeacdgbggaefddebabbfgeacdgbefaecfddffeddacbabfcgecedacbffeddacbabfebadggfafabcdfdeaabdeecgbcecegcgecedacbfgdagbgagafdegecadfebcdbgfacdecdegecadfebbcdfdeaabdbfgcbccfcaebcecfdfccagdafaeaacbggaefddebcbecdafageeaabcbdafadcbecdbcgcbdgedcfadbcaefbdfcbgfcdeceddaaffgcedfcdcgdcgbfdddfdadgagbbef...

output:

3978

result:

wrong answer expected '5594', found '3978'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%