結果
問題 | No.421 しろくろチョコレート |
ユーザー |
|
提出日時 | 2016-09-11 00:03:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,194 bytes |
コンパイル時間 | 1,036 ms |
コンパイル使用メモリ | 76,780 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-17 00:07:55 |
合計ジャッジ時間 | 2,506 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 WA * 43 |
ソースコード
#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;}