QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#579463#9229. Juliet Unifies OnesLX1288#WA 0ms3864kbC++14652b2024-09-21 13:58:172024-09-21 13:58:18

Judging History

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

  • [2024-09-21 13:58:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3864kb
  • [2024-09-21 13:58:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline int rd() {
	int x=0,w=0;char ch=0;
	while(ch<48||ch>57)w|=ch==45,ch=getchar();
	while(ch>=48&&ch<=57)x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}

string s;
int main(){
	ios::sync_with_stdio(false),cin.tie(0);
	cin>>s;
	int n=s.size();
	int cnt=0;
	for(int i=0;i<n;i++)if(s[i]=='1')cnt++;
	int ans=1e6;
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			int cnt1=0,cnt2=0;
			for(int o=i;o<=j;o++){
				if(s[o]=='1')cnt1++;
				else cnt2++;
			}
//			printf("%d %d %d\n",cnt2,cnt,cnt1);
			ans=min(ans,cnt2+cnt-cnt1);
		}
	}
	printf("%d\n",ans);
	return 0;
}

详细

Test #1:

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

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

11101111111111111101001011110111111110011101010110

output:

11

result:

ok 1 number(s): "11"

Test #3:

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

input:

00000000100000000000100000010001000

output:

3

result:

ok 1 number(s): "3"

Test #4:

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

input:

00000000000000000000000000000000000000000000000000

output:

1

result:

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