結果
| 問題 |
No.421 しろくろチョコレート
|
| ユーザー |
alpha_virginis
|
| 提出日時 | 2016-09-10 00:09:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,741 bytes |
| コンパイル時間 | 1,720 ms |
| コンパイル使用メモリ | 166,968 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-16 18:57:50 |
| 合計ジャッジ時間 | 2,951 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 43 WA * 22 |
ソースコード
#include <bits/stdc++.h>
char field[64][64];
int h, w;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
bool outOfRange(int r, int c) {
if( not ( 0 <= r and r < h and 0 <= c and c < w ) ) return true;
return false;
}
int main() {
scanf("%d %d", &h, &w);
for(int i = 0; i < h; ++i) {
scanf("%s", field[i]);
}
int res = 0;
bool updated = false;
int w_count = 0, b_count = 0;
do {
updated = false;
for(int r = 0; r < h; ++r) {
for(int c = 0; c < w; ++c) {
if( field[r][c] == '.' ) continue;
int count = 0;
int kk = -1;
for(int k = 0; k < 4; ++k) {
int nr = r + dr[k], nc = c + dc[k];
if( outOfRange(nr, nc) ) continue;
if( field[nr][nc] == '.' ) continue;
count += 1;
kk = k;
}
if( count == 0 ) {
switch( field[r][c] ) {
case 'w' : w_count += 1;
break;
case 'b' : b_count += 1;
break;
}
field[r][c] = '.';
updated = true;
}
if( count == 1 ) {
field[r][c] = field[r+dr[kk]][c+dc[kk]] = '.';
res += 100;
updated = true;
}
}
}
} while( updated );
int w2_count = 0, b2_count = 0;
for(int r = 0; r < h; ++r) {
for(int c = 0; c < w; ++c) {
switch( field[r][c] ) {
case 'w' : w2_count += 1;
break;
case 'b' : b2_count += 1;
break;
}
}
}
res += 100 * std::min(w2_count, b2_count);
w_count += w2_count - std::min(w2_count, b2_count);
b_count += b2_count - std::min(w2_count, b2_count);
res += 10 * std::min(w_count, b_count) + std::abs(w_count - b_count);
printf("%d\n", res);
return 0;
}
alpha_virginis