Skip to content

Instantly share code, notes, and snippets.

@lawrencefmm
Last active June 17, 2020 15:26
Show Gist options
  • Save lawrencefmm/38c6b9ee97a16a8bdd0a2d691f567b35 to your computer and use it in GitHub Desktop.
Save lawrencefmm/38c6b9ee97a16a8bdd0a2d691f567b35 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
string s;
cin >> n;
cin >> s;
int sets0 = 0, sets1 = 0;
int qtd0 = 0, qtd1 = 0;
for (int i=0; i<s.size(); i++) {
if (s[i] == '0') qtd0++;
else qtd1++;
if (qtd0 == 2) {
sets0++;
qtd0 = qtd1 = 0;
} else if (qtd1 == 2) {
sets1++;
qtd0 = qtd1 = 0;
}
}
if (sets0 == sets1) cout << -1 << endl;
else cout << (sets0 > sets1 ? 0 : 1) << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment