結果

問題 No.421 しろくろチョコレート
ユーザー utouto97utouto97
提出日時 2019-02-14 11:15:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,602 bytes
コンパイル時間 2,221 ms
コンパイル使用メモリ 145,060 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-11 12:33:10
合計ジャッジ時間 5,079 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

int n, m;
string s[50];

pii dfs(int y, int x)
{
  pii res = mp(0, 0);
  if(s[y][x] == 'w'){
    res.first++;
  }else if(s[y][x] == 'b'){
    res.second++;
  }

  s[y][x] = '.';

  int dx[] = {1, -1, 0, 0};
  int dy[] = {0, 0, 1, -1};
  rep(i, 4){
    int nx = x + dx[i];
    int ny = y + dy[i];

    if(nx < 0 or m <= nx or ny < 0 or n <= ny) continue;

    if(s[ny][nx] != '.'){
      pii p = dfs(ny, nx); 
      res.first += p.first;
      res.second += p.second;
    }
  }

  return res;
}

int main()
{
  cin >> n >> m;
  rep(i, n) cin >> s[i];

  int ans = 0;
  pii cnt;
  rep(i, n){
    rep(j, m){
      if(s[i][j] != '.'){
        pii p = dfs(i, j);
        int mi = min(p.first, p.second);
        ans += 100*mi;
        cnt.first += p.first - mi;
        cnt.second += p.second - mi;
      }
    }
  }

  int mi = min(cnt.first, cnt.second);
  ans += 10*mi;
  ans += cnt.first-mi + cnt.second-mi;

  cout << ans << endl;
  
  return 0;
}
0