QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#548662#9229. Juliet Unifies OnesIceCang_#WA 0ms3852kbC++23713b2024-09-05 19:53:372024-09-05 19:53:38

Judging History

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

  • [2024-09-05 19:53:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3852kb
  • [2024-09-05 19:53:37]
  • 提交

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;
	}
	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: 3556kb

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

11101111111111111101001011110111111110011101010110

output:

11

result:

ok 1 number(s): "11"

Test #3:

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

input:

00000000100000000000100000010001000

output:

3

result:

ok 1 number(s): "3"

Test #4:

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

input:

00000000000000000000000000000000000000000000000000

output:

2147483647

result:

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