Code Submission Evaluation System Login

HIIT Open 2018

Start:2018-05-26 11:00:00
End:2018-05-26 16:00:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - HIIT Open 2018 - Results
History
2018-05-26 11:36:38
Task:Inversions
Sender:HIIT AND RUN
Submission time:2018-05-26 11:36:38
Language:C++
Status:READY
Result:ACCEPTED

Test results

testverdicttime (s)
#1ACCEPTED0.05 / 1.00details
#2ACCEPTED0.04 / 1.00details
#3ACCEPTED0.05 / 1.00details
#4ACCEPTED0.04 / 1.00details
#5ACCEPTED0.05 / 1.00details

Compiler report

input/code.cpp:5:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
input/code.cpp: In function 'int main()':
input/code.cpp:11:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); ++i) {
                     ~~^~~~~~~~~~

Code

#include <bits/stdc++.h>

using namespace std;

main () {
    string s;
    cin >> s;
    
    int s1 = 0, s2 = 0;
    
    for (int i = 0; i < s.size(); ++i) {
        
        if (i % 2 == 0) {
            if (s[i] == '0')
                s2 ++;
            if (s[i] == '1')
                s1 ++;
        } else {
            if (s[i] == '0')
                s1 ++;
            if (s[i] == '1')
                s2 ++;
        }
    }
    
    cout << min(s1, s2) << endl;
}

Test details

Test 1

Verdict: ACCEPTED

input
000000000000000000000000000000...
view   save

correct output
500000
view   save

user output
500000
view   save

Test 2

Verdict: ACCEPTED

input
111111111111111111111111111111...
view   save

correct output
500000
view   save

user output
500000
view   save

Test 3

Verdict: ACCEPTED

input
010101010101010101010101010101...
view   save

correct output
0
view   save

user output
0
view   save

Test 4

Verdict: ACCEPTED

input
101010101010101010101010101010...
view   save

correct output
0
view   save

user output
0
view   save

Test 5

Verdict: ACCEPTED

input
110101011010110100100111110110...
view   save

correct output
499476
view   save

user output
499476
view   save