QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#549270 | #9229. Juliet Unifies Ones | puppet# | WA | 0ms | 3688kb | C++14 | 846b | 2024-09-06 13:44:01 | 2024-09-06 13:44:01 |
Judging History
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'