/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 16ms 552.0 KiB
#3 Wrong Answer 5ms 540.0 KiB

Code

#include <iostream>
#include <string>

using namespace std;

int main() {
    int T;
    cin >> T;

    while (T--) {
        int N;
        cin >> N;
        string S;
        cin >> S;

        // Count the total number of 1s and 0s
        int oneCount = 0, zeroCount = 0;
        for (char c : S) {
            if (c == '1') {
                oneCount++;
            } else {
                zeroCount++;
            }
        }

        // If there are more 1s, Roy can always win by flipping 0s to 1s
        // If there are more 0s or equal, Emon can always prevent a long streak of 1s
        if (oneCount > zeroCount) {
            cout << oneCount << endl;
        } else {
            cout << min(oneCount, 1) << endl;
        }
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1113 Fliping Game
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-06 14:05:47
Judged At
2024-11-06 14:05:47
Judged By
Score
5
Total Time
16ms
Peak Memory
552.0 KiB