QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#535612#9229. Juliet Unifies Onesthangthang#WA 0ms3856kbC++20738b2024-08-28 11:04:352024-08-28 11:04:39

Judging History

This is the latest submission verdict.

  • [2024-08-28 11:04:39]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3856kb
  • [2024-08-28 11:04:35]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

int dp[55][3];

void solve(){
    string s; cin >> s; int n = s.size(); s = ' ' + s;
    for (int i = 1; i <= n; ++ i){
        for (int t : {0, 1, 2}) dp[i][t] = n;
        if (s[i] == '0'){
            dp[i][0] = dp[i - 1][0];
            dp[i][2] = min(dp[i - 1][1], dp[i - 1][2]);
            dp[i][1] = dp[i - 1][1] + 1;
        }
        else {
            dp[i][0] = dp[i - 1][0] + 1;
            dp[i][1] = min(dp[i][1], dp[i][0]);
            dp[i][2] = dp[i][2] + 1;
        }
    }

    cout << min({dp[n][0], dp[n][1], dp[n][2]});
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3856kb

input:

00011011001

output:

5

result:

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