結果

問題 No.421 しろくろチョコレート
ユーザー mayoko_mayoko_
提出日時 2016-09-09 23:13:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,462 bytes
コンパイル時間 870 ms
コンパイル使用メモリ 100,580 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 05:51:40
合計ジャッジ時間 5,136 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 AC 2 ms
5,376 KB
testcase_09 RE -
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 RE -
testcase_21 RE -
testcase_22 WA -
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 2 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 2 ms
5,376 KB
testcase_29 WA -
testcase_30 RE -
testcase_31 AC 2 ms
5,376 KB
testcase_32 RE -
testcase_33 WA -
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 WA -
testcase_37 RE -
testcase_38 WA -
testcase_39 WA -
testcase_40 RE -
testcase_41 RE -
testcase_42 WA -
testcase_43 WA -
testcase_44 RE -
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 RE -
testcase_48 RE -
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 RE -
testcase_52 WA -
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 WA -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

string field[55];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> field[i];
    }
    int ans = 0;
    while (1) {
        bool finish = true;
        for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) {
            if (field[i][j] != '.') {
                int degree = 0;
                for (int k = 0; k < 4; k++) {
                    int y = i+dy[k], x = j+dx[k];
                    if (y < 0 || y >= N || x < 0 || x >= M) continue;
                    if (field[y][x] != '.') degree++;
                }
                if (degree == 1) {
                    finish = false;
                    for (int k = 0; k < 4; k++) {
                        int y = i+dy[k], x = j+dx[k];
                        if (y < 0 || y >= N || x < 0 || x >= M) continue;
                        if (field[y][x] != '.') {
                            ans += 100;
                            field[y][x] = '.';
                            field[i][j] = '.';
                        }
                    }
                }
            }
        }
        if (finish) break;
    }
    int W = 0, B = 0, ALL = 0;
    for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) {
        if (field[i][j] != '.') {
            int degree = 0;
            for (int k = 0; k < 4; k++) {
                int y = i+dy[k], x = j+dx[k];
                if (y < 0 || y >= N || x < 0 || x >= M) continue;
                if (field[y][x] != '.') degree++;
            }
            if (!degree) {
                if (field[i][j] == 'w') W++;
                else B++;
            } else {
                ALL++;
            }
        }
    }
    assert(ALL%2 == 0);
    ans += ALL*50;
    ans += 10 * min(W, B);
    ans += max(W, B) - min(W, B);
    cout << ans << endl;
    return 0;
}
0