Submission #1363636


Source Code Expand

#include<iostream>
#include<string>


using namespace std;

int main(){
  string str;
  cin >> str;
  int count[21]={0};

  int ans[26] = {0};
 
  for(int j = 0; j < 26;j++){
    int t = -1,now = 0;
    for(int i = 0;i < str.length();i++){
      if(str[i] == 'a' + j){
	now = i;
	if(ans[j] < now - t){
	  ans[j] = now - t - 1;
	  //cout << ans[j] << endl;

	}
	t = now;
	
      }
    }
    if(ans[j] < str.length() - t - 1){
      ans[j] = str.length() - t - 1;
    }
  }
  int min = 999;
  for(int i = 0;i < 26;i++){
    if(ans[i] != 0 && min > ans[i]) min = ans[i];
  }
  int f = 1;
  for(int i = 0; i < str.length() - 1;i++){
    if(str[i] != str[i+1]) f = 0;
  }
  if(f == 0)cout << min;
  else cout << "0";
  
}

Submission Info

Submission Time
Task A - Shrinking
User kodamune
Language C++14 (GCC 5.4.1)
Score 300
Code Size 760 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 14
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
0_03.txt AC 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 1 ms 256 KB
1_02.txt AC 1 ms 256 KB
1_03.txt AC 1 ms 256 KB
1_04.txt AC 1 ms 256 KB
1_05.txt AC 1 ms 256 KB
1_06.txt AC 1 ms 256 KB
1_07.txt AC 1 ms 256 KB
1_08.txt AC 1 ms 256 KB
1_09.txt AC 1 ms 256 KB