QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#529413#9229. Juliet Unifies Onesucup-team1004#WA 0ms4068kbC++141.4kb2024-08-24 13:07:452024-08-24 13:07:46

Judging History

你现在查看的是最新测评结果

  • [2024-08-24 13:07:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4068kb
  • [2024-08-24 13:07:45]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e6+5,M=N*2+5,K=1e7+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
char s[N];int n;
void Solve(){
	scanf("%s",s+1);n=strlen(s+1);
	if(find(s+1,s+n+1,'0')-s>n){puts("0");return;}
	int ans=n;
	for(int i=1;i<=n;i++)if(s[i]=='1'){
		for(int j=i;j<=n;j++) if(s[j]=='1'){
			int cnt=count(s+1,s+i,'1')+count(s+j+1,s+n+1,'1');
			cnt+=count(s+i,s+j+1,'0');
			ans=min(ans,cnt);
		}
	}
	printf("%d\n",ans);
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 4068kb

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3956kb

input:

11101111111111111101001011110111111110011101010110

output:

11

result:

ok 1 number(s): "11"

Test #3:

score: 0
Accepted
time: 0ms
memory: 4028kb

input:

00000000100000000000100000010001000

output:

3

result:

ok 1 number(s): "3"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3992kb

input:

00000000000000000000000000000000000000000000000000

output:

50

result:

wrong answer 1st numbers differ - expected: '0', found: '50'