QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#548666#9229. Juliet Unifies OnesIceCang_#WA 0ms3784kbC++23763b2024-09-05 19:55:182024-09-05 19:55:22

Judging History

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

  • [2024-09-05 19:55:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3784kb
  • [2024-09-05 19:55:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

int pre[60], a[60];
int tot;
int prefix0, suffix0;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int ans = INT_MAX;
	string str;
	cin>>str;
	int l = str.length();
	for(int i=0;i<l;i++) {
		if(str[i]=='0') prefix0++;
		if(str[i]=='1') break;
	}
	if(prefix0==l) {
		cout<<"0";
		return 0;
	}
	for(int i=l-1;i>0;i--) {
		if(str[i]=='0') suffix0++;
		if(str[i]=='1') break;
	}
	for(int i=prefix0;i<l-suffix0;i++) {
		a[++tot] = str[i]-'0';
		pre[tot] = pre[tot-1] + a[tot];
	} 
	for(int i=1;i<=tot;i++) {
		ans = min(ans, i-1-pre[i-1]+pre[tot]-pre[i-1]); 
	}
	for(int i=1;i<=tot;i++) {
		ans = min(ans, pre[i-1]+(tot-i+1-pre[tot]+pre[i-1])); 
	}
	cout<<ans;
	return 0;
} 

詳細信息

Test #1:

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

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

11101111111111111101001011110111111110011101010110

output:

11

result:

ok 1 number(s): "11"

Test #3:

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

input:

00000000100000000000100000010001000

output:

3

result:

ok 1 number(s): "3"

Test #4:

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

input:

00000000000000000000000000000000000000000000000000

output:

0

result:

ok 1 number(s): "0"

Test #5:

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

input:

00000000100000000000100000011000

output:

2

result:

ok 1 number(s): "2"

Test #6:

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

input:

11000010100100000011101100000001000100000000000000

output:

10

result:

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