Submission #1359353
Source Code Expand
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF 1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...)
#endif
inline LL getint(){
LL _x=0,_tmp=1; char _tc=getchar();
while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
if( _tc == '-' ) _tc=getchar() , _tmp = -1;
while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
_x += _y;
return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
_x -= _y;
return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
_x *= _y;
return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
if( _x == 0 ) return 1LL;
LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
if( _x & 1 ) _ret = mul( _ret , _a , _mod );
return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
if( _x == 0 ) return 0LL;
LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
if( _x & 1 ) _ret = add( _ret , _a , _mod );
return _ret;
}
inline bool equal( D _x , D _y ){
return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 111
void build(){
}
int ans , len;
char c[ N ];
void init(){
scanf( "%s" , c );
len = strlen( c );
}
int vv[ N ] , v2[ N ];
void go( char ctmp ){
for( int i = 0 ; i < len ; i ++ )
vv[ i ] = ( c[ i ] == ctmp );
int tans = 0;
for( int i = len ; i ; i -- ){
if( accumulate( vv , vv + i , 0 ) == i ){
ans = min( ans , tans );
return;
}
tans ++;
for( int j = 0 ; j < i ; j ++ )
v2[ j ] = vv[ j ];
for( int j = 0 ; j + 1 < i ; j ++ )
if( v2[ j ] or v2[ j + 1 ] )
vv[ j ] = 1;
else
vv[ j ] = 0;
}
}
void solve(){
ans = len - 1;
for( int i = 0 ; i < len ; i ++ )
go( c[ i ] );
printf( "%d\n" , ans );
}
int main(){
build();
//__ = getint();
while( __ -- ){
init();
solve();
}
}
Submission Info
Submission Time
2017-06-18 21:03:40+0900
Task
A - Shrinking
User
eddy1021
Language
C++14 (GCC 5.4.1)
Score
300
Code Size
2506 Byte
Status
AC
Exec Time
2 ms
Memory
256 KB
Compile Error
./Main.cpp: In function ‘void init()’:
./Main.cpp:67:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf( "%s" , c );
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
300 / 300
Status
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
2 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
2 ms
256 KB
1_07.txt
AC
1 ms
256 KB
1_08.txt
AC
2 ms
256 KB
1_09.txt
AC
2 ms
256 KB