以下の内容はhttps://blog.hamayanhamayan.com/entry/2019/04/14/001053より取得しました。


Coloring Colorfully [AtCoder Beginner Contest 124 C]

https://atcoder.jp/contests/abc124/tasks/abc124_c

解説

https://atcoder.jp/contests/abc124/submissions/4963281

最終的な形は「101010...」か「010101...」しかないので、どちらも試す。
最終的な目標と違っている個数分だけ塗り替えが必要なので、その塗り替え回数が小さい方が答え。

string S;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;
 
	int ans = inf;
	int N = S.length();
 
	// 10101...
	{
		int cnt = 0;
		rep(i, 0, N) if ((S[i] - '0') == i % 2) cnt++;
		chmin(ans, cnt);
	}
 
	// 01010...
	{
		int cnt = 0;
		rep(i, 0, N) if ((S[i] - '0') != i % 2) cnt++;
		chmin(ans, cnt);
	}
 
	cout << ans << endl;
}



以上の内容はhttps://blog.hamayanhamayan.com/entry/2019/04/14/001053より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14