結果

問題 No.421 しろくろチョコレート
ユーザー masamasa
提出日時 2016-09-11 00:03:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,194 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 76,460 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 10:07:01
合計ジャッジ時間 2,477 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 3 ms
5,376 KB
testcase_30 WA -
testcase_31 AC 3 ms
5,376 KB
testcase_32 AC 3 ms
5,376 KB
testcase_33 WA -
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 2 ms
5,376 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 2 ms
5,376 KB
testcase_63 AC 1 ms
5,376 KB
testcase_64 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int n, m;
vector<string> choco;

bool change() {
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			char c1 = choco[i][j];
			if (c1 == '.') {
				continue;
			}
			for (int k = 0; k < 4; k++) {
				int ni = i + dy[k];
				int nj = j + dx[k];
				char c2 = choco[ni][nj];
				if (c2 != '.' && c1 != c2) {
					choco[i][j] = '.';
					choco[ni][nj] = '.';
					return true;
				}
			}
		}
	}
	return false;
}

int main() {
	string s;
	cin >> n >> m;

	choco.emplace_back(string(m+2, '.'));
	for (int i = 0; i < n; i++) {
		cin >> s;
		s = "." + s  + ".";
		choco.emplace_back(s);
	}
	choco.emplace_back(string(m+2, '.'));

	int score = 0;
	while (1) {
		bool update = change();
		if (update) {
			score += 100;
		} else {
			break;
		}
	}

	int nw = 0;
	int nb = 0;
	for (auto ccc : choco) {
		for (auto c : ccc) {
			if (c == 'b') {
				nb++;
			} else if (c == 'w') {
				nw++;
			}
		}
	}
	score += 10 * min(nw, nb) + abs(nw - nb);


	cout << score << endl;
	return 0;
}
0