Submission #856800


Source Code Expand

Copy
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  string w;
  cin>>w;
  char cl='A';
  in n=sz(w);
  forn(i,n){
    if(cl=='A')
      cl=w[i];
    if(cl!=w[i])
      cl='B';
  }
  if(cl!='B'){
    cout<<n<<endl<<1<<endl;
    return 0;
  }
  in pd=n;
  for(in i=2;i<n;++i){
    if(n%i)
      continue;
    bool ok=1;
    forn(j,n-i){
      if(w[j]!=w[j+i]){
	ok=0;
	break;
      }
    }
    if(ok){
      pd=i;
      break;
    }
  }
  if(pd==n){
    cout<<1<<endl<<1<<endl;
    return 0;
  }
  VI isb(n+1,0);
  VI isr(n+1,0);
  for(in p=1;2*p<=n;++p){
    forn(i,n-p){
      if(w[i]!=w[i+p])
	break;
      if((i+1)%p==0)
	isb[i+p]=1;
    }
    for(in i=n-1;i>=p;--i){
      if(w[i]!=w[i-p])
	break;
      if((n-i)%p==0)
	isr[i-p]=1;
    }
  }
  in sm=0;
  for(in i=0;i<=n-1;++i){
    if(!isb[i] && !isr[i+1])
      ++sm;
  }
  cout<<2<<endl<<sm<<endl;
  return 0;
}

Submission Info

Submission Time
Task F - Best Representation
User w4yneb0t
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1399 Byte
Status TLE
Exec Time 2106 ms
Memory 8732 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 400 / 400 0 / 500
Status
AC × 3
AC × 36
AC × 54
TLE × 11
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 5 ms 384 KB
subtask1_12.txt AC 5 ms 384 KB
subtask1_13.txt AC 5 ms 384 KB
subtask1_14.txt AC 4 ms 384 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 117 ms 384 KB
subtask1_20.txt AC 4 ms 256 KB
subtask1_21.txt AC 79 ms 384 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 24 ms 384 KB
subtask1_26.txt AC 12 ms 384 KB
subtask1_27.txt AC 12 ms 384 KB
subtask1_28.txt AC 9 ms 384 KB
subtask1_29.txt AC 9 ms 384 KB
subtask1_30.txt AC 5 ms 384 KB
subtask1_31.txt AC 5 ms 384 KB
subtask1_32.txt AC 6 ms 384 KB
subtask1_33.txt AC 4 ms 384 KB
subtask2_01.txt AC 127 ms 6932 KB
subtask2_02.txt AC 8 ms 1172 KB
subtask2_03.txt AC 16 ms 1172 KB
subtask2_04.txt AC 17 ms 1172 KB
subtask2_05.txt AC 8 ms 1172 KB
subtask2_06.txt AC 49 ms 1172 KB
subtask2_07.txt AC 16 ms 1172 KB
subtask2_08.txt AC 16 ms 1172 KB
subtask2_09.txt AC 176 ms 8732 KB
subtask2_10.txt AC 173 ms 8732 KB
subtask2_11.txt AC 188 ms 8732 KB
subtask2_12.txt AC 37 ms 8732 KB
subtask2_13.txt TLE 2106 ms 8732 KB
subtask2_14.txt AC 16 ms 1172 KB
subtask2_15.txt TLE 2106 ms 8732 KB
subtask2_16.txt AC 16 ms 1172 KB
subtask2_17.txt AC 17 ms 1172 KB
subtask2_18.txt AC 16 ms 1172 KB
subtask2_19.txt TLE 2106 ms 8732 KB
subtask2_20.txt TLE 2106 ms 8732 KB
subtask2_21.txt TLE 2102 ms 8092 KB
subtask2_22.txt TLE 2106 ms 8732 KB
subtask2_23.txt TLE 2106 ms 8732 KB
subtask2_24.txt TLE 2102 ms 7452 KB
subtask2_25.txt TLE 2106 ms 7836 KB
subtask2_26.txt TLE 2106 ms 8220 KB
subtask2_27.txt TLE 2102 ms 7068 KB
subtask2_28.txt AC 11 ms 720 KB
subtask2_29.txt AC 52 ms 6940 KB