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:22:19
Task:Inversions
Sender:KnowYourArchitecture
Submission time:2018-05-26 11:22:19
Language:C++
Status:READY
Result:ACCEPTED

Test results

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

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128 lll;
/*
lll powmod(lll a, lll p, lll mod) {
	if(p==0) return 1;
		if(p%2==0) {
			a=powmod(a,p/2,mod);
			return (a*a)%mod;
		}
	}
	return (a*powmod(a,p-1,mod))%mod);
}

void step(ll&x, ll n, ll c){x=(lll)((lll)x*(lll)x+(lll)c)%n;}
void rFactor(ll n, map<ll, ll>& r) {
	while(n%2==0) {
		n/=2;r[2]++;
	}
	if(n==1) return;
	if(isPrime(n))r[n]++;
	else {
		while(1){
			ll x=rand()%n;ll y=x;
			ll c=rand()%n;
			for(ll i=0;i*i<=n;i++){
				step(x,n,c);step(x,n,c);step(y,n,c);
				ll g=__gcd(max(x,y)-min(x,y),n);
				if(g==n)break;
				else if(g>1) {
					rFactor(n/g, r);
					rFactor(g,r);
					return;
				}
			}
		}
	}
}

map<ll,ll> factor(ll n){
	map<ll,ll> ret;
	if(n>1) rFactor(n,ret);
	return ret;
}
*/
int main(){
	string a;
	cin>>a;
	ll ra=0;
	ll rb=0;
	ll i=0;
	for(auto& v : a){
		if((v-'0') == (i&1)) ra++;
		else rb++;
		++i;
	}
	cout<<min(ra,rb)<<'\n';
}

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