Submission #857275


Source Code Expand

Copy
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;

char s[600000];
int n, nxt[600000], nxt2[600000];
int main(){
	scanf("%s", s+1);
	n = strlen(s+1);
	FOR(i,2,n) {
		int j = nxt[i-1];
		for (; j > 0 && s[j+1] != s[i]; j = nxt[j]);
		if (s[j+1] == s[i]) nxt[i] = j+1; else nxt[i] = 0;
		
		j = nxt2[i-1];
		for (; j > 0 && s[n+1-(j+1)] != s[n+1-i]; j = nxt2[j]);
		if (s[n+1-(j+1)] == s[n+1-i]) nxt2[i] = j+1; else nxt2[i] = 0;
	}
	int L = n-nxt[n];
	if (n%L || L == n) printf("1\n1\n");
	else if (L == 1) printf("%d\n%d\n", n, 1);
	else {
		int t;
		if (L*2 == n) t = n-1; else t = n/L*(L-1);
		REP(i,L-1) { 
			if (nxt[i] > 0 && i%(i-nxt[i]) == 0) --t;
			if (nxt2[i] > 0 && i%(i-nxt2[i]) == 0) --t;
		}
		printf("%d\n%d\n", 2, t);
	}
	return 0;
}

Submission Info

Submission Time
Task F - Best Representation
User crx
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1080 Byte
Status WA
Exec Time 19 ms
Memory 4608 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:17:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", s+1);
                  ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 400 0 / 500
Status
AC × 3
AC × 35
WA × 1
AC × 63
WA × 2
Set Name Test Cases
Sample example_01.txt, example_02.txt, example_03.txt
Subtask1 example_01.txt, example_02.txt, example_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt, subtask1_26.txt, subtask1_27.txt, subtask1_28.txt, subtask1_29.txt, subtask1_30.txt, subtask1_31.txt, subtask1_32.txt, subtask1_33.txt
All example_01.txt, example_02.txt, example_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt, subtask1_25.txt, subtask1_26.txt, subtask1_27.txt, subtask1_28.txt, subtask1_29.txt, subtask1_30.txt, subtask1_31.txt, subtask1_32.txt, subtask1_33.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_20.txt, subtask2_21.txt, subtask2_22.txt, subtask2_23.txt, subtask2_24.txt, subtask2_25.txt, subtask2_26.txt, subtask2_27.txt, subtask2_28.txt, subtask2_29.txt
Case Name Status Exec Time Memory
example_01.txt AC 4 ms 256 KB
example_02.txt AC 4 ms 256 KB
example_03.txt AC 4 ms 256 KB
subtask1_01.txt AC 4 ms 256 KB
subtask1_02.txt AC 4 ms 256 KB
subtask1_03.txt WA 4 ms 256 KB
subtask1_04.txt AC 4 ms 256 KB
subtask1_05.txt AC 4 ms 256 KB
subtask1_06.txt AC 4 ms 256 KB
subtask1_07.txt AC 4 ms 256 KB
subtask1_08.txt AC 4 ms 256 KB
subtask1_09.txt AC 4 ms 256 KB
subtask1_10.txt AC 4 ms 256 KB
subtask1_11.txt AC 4 ms 256 KB
subtask1_12.txt AC 4 ms 256 KB
subtask1_13.txt AC 4 ms 256 KB
subtask1_14.txt AC 4 ms 256 KB
subtask1_15.txt AC 4 ms 256 KB
subtask1_16.txt AC 4 ms 256 KB
subtask1_17.txt AC 4 ms 256 KB
subtask1_18.txt AC 4 ms 256 KB
subtask1_19.txt AC 4 ms 256 KB
subtask1_20.txt AC 4 ms 256 KB
subtask1_21.txt AC 4 ms 256 KB
subtask1_22.txt AC 4 ms 256 KB
subtask1_23.txt AC 4 ms 256 KB
subtask1_24.txt AC 4 ms 256 KB
subtask1_25.txt AC 4 ms 256 KB
subtask1_26.txt AC 4 ms 256 KB
subtask1_27.txt AC 4 ms 256 KB
subtask1_28.txt AC 4 ms 256 KB
subtask1_29.txt AC 4 ms 256 KB
subtask1_30.txt AC 4 ms 256 KB
subtask1_31.txt AC 4 ms 256 KB
subtask1_32.txt AC 4 ms 256 KB
subtask1_33.txt AC 4 ms 256 KB
subtask2_01.txt WA 15 ms 3712 KB
subtask2_02.txt AC 15 ms 4608 KB
subtask2_03.txt AC 15 ms 4608 KB
subtask2_04.txt AC 17 ms 4608 KB
subtask2_05.txt AC 16 ms 4608 KB
subtask2_06.txt AC 16 ms 4608 KB
subtask2_07.txt AC 18 ms 4608 KB
subtask2_08.txt AC 15 ms 4608 KB
subtask2_09.txt AC 19 ms 4608 KB
subtask2_10.txt AC 18 ms 4608 KB
subtask2_11.txt AC 19 ms 4608 KB
subtask2_12.txt AC 16 ms 4608 KB
subtask2_13.txt AC 14 ms 4608 KB
subtask2_14.txt AC 16 ms 4608 KB
subtask2_15.txt AC 15 ms 4608 KB
subtask2_16.txt AC 14 ms 4608 KB
subtask2_17.txt AC 17 ms 4608 KB
subtask2_18.txt AC 16 ms 4608 KB
subtask2_19.txt AC 19 ms 4608 KB
subtask2_20.txt AC 19 ms 4608 KB
subtask2_21.txt AC 15 ms 4352 KB
subtask2_22.txt AC 15 ms 4608 KB
subtask2_23.txt AC 14 ms 4608 KB
subtask2_24.txt AC 14 ms 3968 KB
subtask2_25.txt AC 14 ms 4224 KB
subtask2_26.txt AC 14 ms 4480 KB
subtask2_27.txt AC 13 ms 3840 KB
subtask2_28.txt AC 10 ms 2560 KB
subtask2_29.txt AC 15 ms 3712 KB