Submission #1898408
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
int x;
char c;
int f=1;
while((c=getchar())!='-' && (c>'9' || c<'0'));
if(c=='-') c=getchar(),f=-1;
x=c^'0';
while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
return x*f;
}
inline ll readll(){
ll x;
char c;
int f=1;
while((c=getchar())!='-' && (c>'9' || c<'0'));
if(c=='-') c=getchar(),f=-1;
x=c^'0';
while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
return x*f;
}
const int maxn=1e5+10;
char s[maxn];
int n;
int main(){
scanf("%s",s+1);
n=strlen(s+1);
int ans1=n,ans2=n;
REP(i,1,n){
if(s[i]=='1') ans1=min(ans1,max(n-i,i-1));
else if(s[i]=='0') ans2=min(ans2,max(n-i,i-1));
}
printf("%d\n",max(ans1,ans2));
// int L=1,R=n;
// while(L<=R){
// int Mid=(L+R)>>1;
// if(check(Mid)) L=Mid+1;
// else R=Mid-1;
// }
// printf("%d\n",L-1);
return 0;
}
Submission Info
Submission Time
2017-12-23 21:34:02+0900
Task
D - Wide Flip
User
zhou888
Language
C++14 (GCC 5.4.1)
Score
500
Code Size
1068 Byte
Status
AC
Exec Time
2 ms
Memory
384 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:30:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%s",s+1);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
500 / 500
Status
Set Name
Test Cases
Sample
s1.txt, s2.txt, s3.txt
All
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, s1.txt, s2.txt, s3.txt
Case Name
Status
Exec Time
Memory
01.txt
AC
2 ms
384 KB
02.txt
AC
2 ms
384 KB
03.txt
AC
2 ms
384 KB
04.txt
AC
2 ms
384 KB
05.txt
AC
2 ms
384 KB
06.txt
AC
2 ms
384 KB
07.txt
AC
2 ms
384 KB
08.txt
AC
2 ms
384 KB
09.txt
AC
2 ms
384 KB
10.txt
AC
2 ms
384 KB
11.txt
AC
2 ms
384 KB
12.txt
AC
2 ms
384 KB
13.txt
AC
2 ms
384 KB
14.txt
AC
2 ms
384 KB
15.txt
AC
2 ms
384 KB
16.txt
AC
2 ms
384 KB
17.txt
AC
2 ms
384 KB
18.txt
AC
1 ms
384 KB
19.txt
AC
1 ms
384 KB
20.txt
AC
1 ms
384 KB
21.txt
AC
1 ms
256 KB
22.txt
AC
1 ms
256 KB
23.txt
AC
1 ms
256 KB
24.txt
AC
1 ms
256 KB
25.txt
AC
1 ms
256 KB
26.txt
AC
1 ms
256 KB
27.txt
AC
1 ms
256 KB
s1.txt
AC
1 ms
256 KB
s2.txt
AC
1 ms
256 KB
s3.txt
AC
1 ms
256 KB