QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#529629#9229. Juliet Unifies OnesEverlasting Journey (Tianshu Li, Luhanming Yao, Keyan Dong)#WA 1ms5872kbC++23983b2024-08-24 13:33:262024-08-24 13:33:27

Judging History

This is the latest submission verdict.

  • [2024-08-24 13:33:27]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5872kb
  • [2024-08-24 13:33:26]
  • Submitted

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];
int ss[N];
void __(){
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++){
        int t=s[i]-'0';
        ss[i]=t;
        ss[i]+=ss[i-1];
    }
    int ans=n-ss[n];
    for(int i=1;i<n;i++){
        // for(int j=i+1;j<=n;j++){
            // ans=min(ans,)
            ll res1=ss[i]+((n-i)-(ss[n]-ss[i]));
            ll res2=(i-ss[i])+(ss[n]-ss[i]);
            // cout<<res1<<" "<<res2<<endl;
            ans=min(ans,min(res1,res2));
        // }
    }
    for(int i=2;i<=n;i++){
        for(int j=i;j<n;j++){
            ll res1=ss[i-1];
            ll res2=(j-i+1)-(ss[j]-ss[i-1]);
            ll res3=ss[n]-ss[j];
            ans=min(ans,res1+res2+res3);
        }
    }
    cout<<ans<<endl;
}


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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5768kb

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

11101111111111111101001011110111111110011101010110

output:

11

result:

ok 1 number(s): "11"

Test #3:

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

input:

00000000100000000000100000010001000

output:

3

result:

ok 1 number(s): "3"

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 5668kb

input:

00000000000000000000000000000000000000000000000000

output:

1

result:

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