結果

問題 No.421 しろくろチョコレート
ユーザー alpha_virginisalpha_virginis
提出日時 2016-09-09 23:50:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,959 bytes
コンパイル時間 1,568 ms
コンパイル使用メモリ 167,392 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 06:01:25
合計ジャッジ時間 3,280 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
  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 == 1 ) {
          field[r][c] = field[r+dr[kk]][c+dc[kk]] = '.';
          res += 100;
          updated = true;
        }
      }
    }
    if( not updated ) {
      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 == 2 ) {
            field[r][c] = field[r+dr[kk]][c+dc[kk]] = '.';
            res += 100;
            updated = true;
            goto label_1;
          }
        }
      }
    label_1:;
    }
  } while( updated );
         
  int w_count = 0, b_count = 0;
  for(int r = 0; r < h; ++r) {
    for(int c = 0; c < w; ++c) {
      switch( field[r][c] ) {
      case 'w' : w_count += 1;
        break;
      case 'b' : b_count += 1;
        break;
      }
    }
  }

  res += 10 * std::min(w_count, b_count) + std::abs(w_count - b_count);
  printf("%d\n", res);
  
  return 0;
}

0