QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#533672#9229. Juliet Unifies OnesYcfhnndWA 0ms3544kbC++23687b2024-08-26 10:19:562024-08-26 10:19:57

Judging History

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

  • [2024-08-26 10:19:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3544kb
  • [2024-08-26 10:19:56]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    cin >> s;

    int n = s.size();
    int l = n, r = 0;
    for (int i = 0;i < n;i ++){
        if (s[i] == '1'){
            l = min(l, i);
            r = i;
        }
    }
    if (l == n){
        cout << 0;
    }else{
        int cnt = 0, ans = 0;
        for (int i = l;i <= r;i ++){
            if (s[i] == '0'){
                cnt ++;
            }else{
                if (cnt) ans ++;
                cnt = 0;
            }
        }
        cout << ans;
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

00011011001

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

11101111111111111101001011110111111110011101010110

output:

9

result:

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