Task: | Inversions |
Sender: | Robotiimi |
Submission time: | 2018-05-26 12:22:06 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.02 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | ACCEPTED | 0.02 s | details |
#4 | ACCEPTED | 0.01 s | details |
#5 | ACCEPTED | 0.03 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:16:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i=1; i<s.size(); i++) { ~^~~~~~~~~
Code
#include <bits/stdc++.h> #include <string> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; int n = 0; for (int i=1; i<s.size(); i++) { if (s[i-1] == s[i]) { if (s[i] == '0') { s[i] = '1'; } else { s[i] = '0'; } n++; } } cout << n << "\n"; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
000000000000000000000000000000... |
correct output |
---|
500000 |
user output |
---|
500000 |
Test 2
Verdict: ACCEPTED
input |
---|
111111111111111111111111111111... |
correct output |
---|
500000 |
user output |
---|
500000 |
Test 3
Verdict: ACCEPTED
input |
---|
010101010101010101010101010101... |
correct output |
---|
0 |
user output |
---|
0 |
Test 4
Verdict: ACCEPTED
input |
---|
101010101010101010101010101010... |
correct output |
---|
0 |
user output |
---|
0 |
Test 5
Verdict: ACCEPTED
input |
---|
110101011010110100100111110110... |
correct output |
---|
499476 |
user output |
---|
499476 |