QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#529458#9229. Juliet Unifies Onesucup-team3474#WA 0ms3972kbC++231.1kb2024-08-24 13:13:122024-08-24 13:13:12

Judging History

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

  • [2024-08-24 13:13:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3972kb
  • [2024-08-24 13:13:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1919810;
typedef int ll;
typedef pair<ll,ll> PII;
int n,m,k;
ll a[N],b[N];
char s[N];

void __(){
    scanf("%s",s+1);
    n=strlen(s+1);
    vector<PII> v;
    int now=s[1]-'0';
    int cnt=0;
    for(int i=1;i<=n;i++){
        int t=s[i]-'0';
        if(t==now){
            cnt++;
        }else{
            v.push_back({now,cnt});
            cnt=1;
            now=t;
        }
    }
    v.push_back({now,cnt});
    int ans=n+1;
    int now1=0,now2=0;
    bool flag=0;
    for(int i=0;i<v.size();i++){
        int t=v[i].first;
        now1+=v[i].second;
        if(t==1){
            flag=1;
            ans=min(ans,n-now1+now2);
        }else{
            ans=min(ans,n-now1+now2);
            if(flag) now2+=v[i].second;
        }
    }
    int cnt1=0;
    for(auto [x,y]:v) if(x==1) cnt1+=y;
    // cout<<cnt1<<endl;
    for(auto [x,y]:v){
        // cout<<x<<" "<<y<<endl;
        if(x==1){
            ans=min(ans,cnt1-y);
        }
    }
    cout<<ans<<endl;
}


int main(){
    int _=1;
    // cin>>_;
    while(_--){
        __();
    }
}

詳細信息

Test #1:

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

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

11101111111111111101001011110111111110011101010110

output:

11

result:

ok 1 number(s): "11"

Test #3:

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

input:

00000000100000000000100000010001000

output:

3

result:

ok 1 number(s): "3"

Test #4:

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

input:

00000000000000000000000000000000000000000000000000

output:

0

result:

ok 1 number(s): "0"

Test #5:

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

input:

00000000100000000000100000011000

output:

2

result:

ok 1 number(s): "2"

Test #6:

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

input:

11000010100100000011101100000001000100000000000000

output:

9

result:

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