Contest Duration: - (local time) (100 minutes) Back to Home

Submission #856009

Source Code Expand

Copy
```#include <stdio.h>
#include <algorithm>
using namespace std;

char A[500050]; int F[500050];
bool cut[500050];

int main()
{
scanf("%s", A);
int l = 0; while (A[l]) l++;
int k = -1; F[0] = -1;
for (int i=1;i<l;i++){
while (k >= 0 && A[k+1] != A[i]) k = F[k];
if (A[k+1] == A[i]) k++;
F[i] = k;
}

if (F[l-1] == l-2){
printf("%d\n%d\n", l, 1);
}
else{
bool good = 1;
for (int i=F[l-1];i>=0;i=F[i]){
int p = l-1 - i;
if (l % p == 0){
if (p*2 != l) for (int j=p;j<=l;j+=p) cut[j] = 1;
good = 0;
}
}

if (good) printf("1\n1\n");
else{
int ans = 0;
for (int i=1;i<l-1;i++) if (F[i] != -1){
int p = i - F[i];
if ((i + 1) % p == 0) cut[i+1] = 1;
}
reverse(A,A+l);

int k = -1; F[0] = -1;
for (int i=1;i<l;i++){
while (k >= 0 && A[k+1] != A[i]) k = F[k];
if (A[k+1] == A[i]) k++;
F[i] = k;
}
for (int i=1;i<l-1;i++) if (F[i] != -1){
int p = i - F[i];
if ((i + 1) % p == 0) cut[l-i] = 1;
}

for (int i=1;i<l;i++) if (!cut[i]) ans++;

printf("%d\n%d\n", 2, ans);
}
}
return 0;
}```

#### Submission Info

Submission Time 2016-08-28 21:43:05+0900 F - Best Representation august14 C++14 (GCC 5.4.1) 0 1133 Byte WA 23 ms 3072 KB

#### Compile Error

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

#### Judge Result

Score / Max Score 0 / 0 0 / 400 0 / 500
Status
 AC × 3
 AC × 27 WA × 9
 AC × 47 WA × 18
Set Name Test Cases
Sample example_01.txt, example_02.txt, example_03.txt
Case Name Status Exec Time Memory
example_01.txt AC 2 ms 128 KB
example_02.txt AC 2 ms 128 KB
example_03.txt AC 2 ms 128 KB
subtask1_01.txt AC 2 ms 128 KB
subtask1_02.txt AC 2 ms 128 KB
subtask1_03.txt AC 2 ms 128 KB
subtask1_04.txt AC 2 ms 128 KB
subtask1_05.txt AC 2 ms 128 KB
subtask1_06.txt AC 2 ms 128 KB
subtask1_07.txt AC 2 ms 128 KB
subtask1_08.txt AC 2 ms 128 KB
subtask1_09.txt AC 2 ms 128 KB
subtask1_10.txt AC 2 ms 128 KB
subtask1_11.txt AC 2 ms 256 KB
subtask1_12.txt AC 2 ms 256 KB
subtask1_13.txt AC 2 ms 128 KB
subtask1_14.txt AC 2 ms 128 KB
subtask1_15.txt AC 2 ms 128 KB
subtask1_16.txt AC 2 ms 128 KB
subtask1_17.txt AC 2 ms 128 KB
subtask1_18.txt AC 2 ms 128 KB
subtask1_19.txt WA 2 ms 128 KB
subtask1_20.txt AC 2 ms 128 KB
subtask1_21.txt WA 2 ms 128 KB
subtask1_22.txt AC 2 ms 128 KB
subtask1_23.txt AC 2 ms 128 KB
subtask1_24.txt AC 2 ms 128 KB
subtask1_25.txt AC 2 ms 128 KB
subtask1_26.txt AC 2 ms 128 KB
subtask1_27.txt WA 2 ms 128 KB
subtask1_28.txt WA 2 ms 128 KB
subtask1_29.txt WA 2 ms 128 KB
subtask1_30.txt WA 3 ms 128 KB
subtask1_31.txt WA 2 ms 128 KB
subtask1_32.txt WA 2 ms 128 KB
subtask1_33.txt WA 2 ms 128 KB
subtask2_01.txt AC 16 ms 2176 KB
subtask2_02.txt AC 10 ms 2560 KB
subtask2_03.txt AC 12 ms 2560 KB
subtask2_04.txt AC 11 ms 2560 KB
subtask2_05.txt AC 10 ms 2560 KB
subtask2_06.txt AC 12 ms 2560 KB
subtask2_07.txt AC 11 ms 2560 KB
subtask2_08.txt AC 10 ms 2560 KB
subtask2_09.txt AC 20 ms 2688 KB
subtask2_10.txt AC 20 ms 2688 KB
subtask2_11.txt AC 20 ms 2688 KB
subtask2_12.txt AC 19 ms 2560 KB
subtask2_13.txt WA 23 ms 3072 KB
subtask2_14.txt AC 11 ms 2560 KB
subtask2_15.txt WA 22 ms 3072 KB
subtask2_16.txt AC 11 ms 2560 KB
subtask2_17.txt AC 10 ms 2560 KB
subtask2_18.txt AC 12 ms 2560 KB
subtask2_19.txt AC 20 ms 2816 KB
subtask2_20.txt AC 21 ms 2816 KB
subtask2_21.txt WA 19 ms 2560 KB
subtask2_22.txt WA 21 ms 3072 KB
subtask2_23.txt WA 20 ms 3072 KB
subtask2_24.txt WA 18 ms 2688 KB
subtask2_25.txt WA 19 ms 2816 KB
subtask2_26.txt WA 20 ms 2944 KB
subtask2_27.txt WA 18 ms 2560 KB
subtask2_28.txt AC 6 ms 1408 KB
subtask2_29.txt AC 16 ms 2048 KB