Submission #856720


Source Code Expand

Copy
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

char S[500005];
int pre[500005];
int front[500005];

int back[500005];

int main()
{
	scanf("%s", S);
	int len = strlen(S);
	{
		int allSame = 1;
		for (int i = 1; i < len; i++) {
			if (S[0] != S[i]) allSame = 0;
		}
		if (allSame) {
			printf("%d\n1\n", len);
			return 0;
		}
	}

	int now = -1;
	pre[0] = -1;
	for (int i = 1; i < len; i++) {
		while (now != -1 && S[i] != S[now + 1]) {
			now = pre[now];
		}
		if (S[i] == S[now + 1]) pre[i] = now = now + 1;
		else pre[i] = now = -1;
		if (now != -1) {
			int last = (i + 1) % (i - now);
			if (last == 0) front[i] = 1;
		}
	}

	reverse(S, S + len);
	now = -1;
	pre[0] = -1;
	for (int i = 1; i < len; i++) {
		while (now != -1 && S[i] != S[now + 1]) {
			now = pre[now];
		}
		if (S[i] == S[now + 1]) pre[i] = now = now + 1;
		else pre[i] = now = -1;
		if (now != -1) {
			int last = (i + 1) % (i - now);
			if (last == 0) back[i] = 1;
		}
	}

	if (front[len - 1] == 0) {
		printf("1\n1\n");
		return 0;
	}
	else {
		int ans = 0;
		for (int i = 0; i <= len - 2; i++) {
			if (front[i] == 0 && back[len - i - 2] == 0)
				ans++;
		}
		printf("2\n%d\n", ans);
		return 0;
	}

	return 0;
}

Submission Info

Submission Time
Task F - Best Representation
User dragoon
Language C++14 (GCC 5.4.1)
Score 900
Code Size 2322 Byte
Status AC
Exec Time 32 ms
Memory 6528 KB

Compile Error

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

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 400 / 400 500 / 500
Status
AC × 3
AC × 36
AC × 65
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 AC 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 6 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 AC 18 ms 2304 KB
subtask2_02.txt AC 8 ms 768 KB
subtask2_03.txt AC 21 ms 4608 KB
subtask2_04.txt AC 20 ms 4608 KB
subtask2_05.txt AC 8 ms 768 KB
subtask2_06.txt AC 21 ms 4608 KB
subtask2_07.txt AC 22 ms 4608 KB
subtask2_08.txt AC 19 ms 2816 KB
subtask2_09.txt AC 23 ms 2816 KB
subtask2_10.txt AC 25 ms 2816 KB
subtask2_11.txt AC 24 ms 2816 KB
subtask2_12.txt AC 20 ms 2688 KB
subtask2_13.txt AC 31 ms 6528 KB
subtask2_14.txt AC 32 ms 6528 KB
subtask2_15.txt AC 29 ms 6528 KB
subtask2_16.txt AC 29 ms 6528 KB
subtask2_17.txt AC 21 ms 4608 KB
subtask2_18.txt AC 26 ms 4608 KB
subtask2_19.txt AC 23 ms 3712 KB
subtask2_20.txt AC 25 ms 3712 KB
subtask2_21.txt AC 22 ms 2816 KB
subtask2_22.txt AC 25 ms 6528 KB
subtask2_23.txt AC 25 ms 6528 KB
subtask2_24.txt AC 22 ms 5248 KB
subtask2_25.txt AC 23 ms 5888 KB
subtask2_26.txt AC 26 ms 6272 KB
subtask2_27.txt AC 23 ms 5376 KB
subtask2_28.txt AC 13 ms 1536 KB
subtask2_29.txt AC 17 ms 2176 KB