QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#21527#2850. 蛋糕Skyowo#WA 6ms5836kbC++141.4kb2022-03-07 14:33:152022-05-08 03:36:04

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-08 03:36:04]
  • Judged
  • Verdict: WA
  • Time: 6ms
  • Memory: 5836kb
  • [2022-03-07 14:33:15]
  • Submitted

answer

// Skyqwq
#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

template <typename T> bool chkMax(T &x, T y) { return (y > x) ? x = y, 1 : 0; }
template <typename T> bool chkMin(T &x, T y) { return (y < x) ? x = y, 1 : 0; }

template <typename T> void inline read(T &x) {
    int f = 1; x = 0; char s = getchar();
    while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); }
    while (s <= '9' && s >= '0') x = x * 10 + (s ^ 48), s = getchar();
    x *= f;
}

const int N = 1e6 + 5;

char s[N];

int n, p[N];

bool st[N];

void inline manacher() {
	int r = 0, mid = 0;
	for (int i = 1; i <= n; i++) {
		p[i] = i <= r ? min(p[2 * mid - i], r - i + 1) : 1;
		while (i - p[i] > 0 && i + p[i] <= n && s[i + p[i]] == s[i - p[i]])
			++p[i];
		if (i + p[i] - 1 > r) r = i + p[i] - 1, mid = i;
	}
}

int main() {
	int T; read(T);
	while (T--) {
		scanf("%s", s + 1);
		n = strlen(s + 1);
		manacher();
		if (n == 1) st[1] = 1;
		for (int i = 1; i <= n; i++) {
			if (i + p[i] - 1 == n) st[i] = 1;
		}
		for (int i = n; i >= 2; i--) {
			if (2 * i - 1 <= n) {
				if (p[i] == i) st[i] |= st[2 * i - 1];
			}
		}
		for (int i = 1; i <= n; i++)
			if (st[i]) printf("%d ", i);
		puts("");
		for (int i = 1; i <= n; i++) st[i] = 0;
	}
    return 0;
}



Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 6ms
memory: 5836kb

input:

9999
18429 66560 1 13694
48994 1 16287 10018
26028 52162 14916 1
30285 52396 33384 55269
65461 96967 74820 73364
55054 70162 1 1
97285 88897 39444 35439
61069 20048 35664 1
21838 22945 6244 79240
46316 82624 33318 31522
90387 93765 7568 97379
22273 74037 1255 91257
67961 28295 1 36263
20958 87638 59...

output:

5 
5 
1 
5 
5 
1 
5 
5 
5 
5 
5 
1 
5 
5 
5 
5 
5 
5 
5 
5 
5 
5 
1 
1 
5 
5 
4 5 
5 
5 
5 
5 
1 
4 5 
5 
4 
5 
5 
5 
5 
5 
5 
5 
4 
3 5 
5 
5 
4 
5 
5 
5 
1 
3 5 
5 
5 
5 
1 
5 
4 
5 
5 
5 
5 
1 
5 
5 
4 
5 
5 
5 
5 
5 
4 5 
5 
5 
5 
4 
4 
1 
5 
5 
1 
5 
4 
5 
5 
5 
5 
5 
5 
5 
5 
1 
4 5 
5 
1 
5 
...

result:

wrong answer 1st lines differ - expected: '0 0 278697304 483210476 394708 8 0 0 0', found: '5 '