Submission #4961559


Source Code Expand

#include <iostream>
#include <string>
using namespace std;

string s;

int main(){
	cin >> s;
	int n = s.length();
	int gi = 0;
	int oo = 0;
	int fixg = 0;
	int fixoo = 0;
	for(int i=0; i<n; i+=2){
		if(s[i]=='1'){
			++gi;
			if(n%2 == 1){
				if(i < n-1 && s[i+1]=='1'){
					++fixg;
				}
			}else{
				if(s[i+1]=='1'){
					++fixg;
				}
			}
		}else if(s[i+1]=='1'){
			++oo;
			if(s[i]=='1'){
				++fixoo;
			}
		}
	}
	if(gi>=oo){
		if(n%2==1){
			cout << fixg + (n-gi*2)/2;
		}else{
			cout << fixg+(n-gi*2)/2+1;
		}
	}else{
		if(n%2==1){
			cout << fixoo+(n-oo*2)/2;			
		}
		cout << fixoo+(n-oo*2)/2;
	}

	
	return 0;
}

Submission Info

Submission Time
Task C - Coloring Colorfully
User esgsms
Language C++14 (GCC 5.4.1)
Score 0
Code Size 675 Byte
Status WA
Exec Time 5 ms
Memory 512 KiB

Judge Result

Set Name All Sample
Score / Max Score 0 / 300 0 / 0
Status
AC × 7
WA × 13
AC × 3
Set Name Test Cases
All sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 AC 1 ms 256 KiB
sample_02 AC 1 ms 256 KiB
sample_03 AC 1 ms 256 KiB
testcase_01 WA 3 ms 384 KiB
testcase_02 WA 3 ms 384 KiB
testcase_03 WA 5 ms 512 KiB
testcase_04 WA 5 ms 512 KiB
testcase_05 WA 4 ms 512 KiB
testcase_06 WA 4 ms 512 KiB
testcase_07 AC 4 ms 512 KiB
testcase_08 WA 4 ms 512 KiB
testcase_09 AC 1 ms 256 KiB
testcase_10 WA 5 ms 512 KiB
testcase_11 WA 5 ms 512 KiB
testcase_12 AC 4 ms 512 KiB
testcase_13 AC 4 ms 512 KiB
testcase_14 WA 4 ms 512 KiB
testcase_15 WA 4 ms 512 KiB
testcase_16 WA 4 ms 512 KiB
testcase_17 WA 4 ms 512 KiB