QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#549270#9229. Juliet Unifies Onespuppet#WA 0ms3688kbC++14846b2024-09-06 13:44:012024-09-06 13:44:01

Judging History

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

  • [2024-09-06 13:44:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3688kb
  • [2024-09-06 13:44:01]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;
struct node 
{
	ll l,r;
}num[10005];
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	string s;
	cin>>s;
	ll l=0;
	ll ans=0;
	while(l<=s.size()-1)
	{
		ll r=l;
		while(r<=s.size()-1&&s[r]=='1')
		{
			r++;
		}
		if(r!=l)
		{
			num[++ans].l=l;
			num[ans].r=r-1;
			l=r;
		}
		l++;
	}
	ll da=1e18;
	for(ll i=1;i<=ans;i++)
	{
		ll cur=0;
		for(ll j=1;j<=i-1;j++)
		{
			ll u1=num[j].r-num[j].l+1;
			ll u2=num[j+1].l-num[j].r-1;
			cur+=min(u1,u2);
		}
		for(ll j=i+1;j<=ans;j++)
		{
			ll u1=num[j].r-num[j].l+1;
			ll u2=num[j].l-num[j-1].r-1;
			cur+=min(u1,u2);
		}
		da=min(da,cur);
	}
	cout<<da<<"\n";
}

详细

Test #1:

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

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

11101111111111111101001011110111111110011101010110

output:

10

result:

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