結果

問題 No.421 しろくろチョコレート
ユーザー kotamanegikotamanegi
提出日時 2016-09-09 23:41:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,794 bytes
コンパイル時間 818 ms
コンパイル使用メモリ 92,488 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 05:58:18
合計ジャッジ時間 2,157 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 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 WA -
testcase_22 WA -
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 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 WA -
testcase_31 AC 2 ms
5,376 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 2 ms
5,376 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 2 ms
5,376 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 2 ms
5,376 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
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 #

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>

using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int choko[1000][1000] = {};
int already_got[1000][1000] = {};
int moved[4] = { 0,0,-1,1 };
int mmove[4] = { 1,-1,0,0 };
int main() {
	int n, m;
	cin >> n >> m;
	REP(i, n) {
		string hoge;
		cin >> hoge;
		REP(q, m) {
			if (hoge[q] == 'w') {
				choko[i+1][q+1] = 1;
			}
			else if(hoge[q] == 'b') {
				choko[i+1][q+1] = 2;
			}
		}
	}
	for (int i = 1;i <= n;++i) {
		for (int q = 1;q <= m;++q) {
			if (choko[i][q] != 0&&already_got[i][q] == false) {
				queue<pair<pair<int,int>,pair<int,int>>> tmp;
				for (int j = 0;j < 4;++j) {
					if (choko[i + mmove[j]][q + moved[j]] != 0&&already_got[i+mmove[j]][q + moved[j]] == 0) {
						tmp.push(make_pair(make_pair(i + mmove[j], q + moved[j]),make_pair(i,q)));
						already_got[i + mmove[j]][q+moved[j]] = 1;
						already_got[i][q] = 1;
						goto aaa;
					}
				}
			aaa:;
				while (tmp.empty() == false) {
					pair<int, int> te = tmp.front().first;
					pair<int, int> to = tmp.front().second;
					tmp.pop();
					int can_go[2] = {-1,-1};
					for (int j = 0;j < 4;++j) {
						if (choko[te.first + mmove[j]][te.second + moved[j]] != 0&&already_got[te.first + mmove[j]][te.second + moved[j]] == false) {
							can_go[0] = j;
						}
						if (choko[to.first + mmove[j]][to.second + moved[j]] != 0 && already_got[to.first + mmove[j]][to.second + moved[j]] == false) {
							can_go[1] = j;
						}
					}
					if (can_go[0] != -1 && can_go[1] != -1) {
						already_got[te.first + mmove[can_go[0]]][te.second + moved[can_go[0]]] = true;
						already_got[to.first + mmove[can_go[1]]][to.second + moved[can_go[1]]] = true;
						tmp.push(make_pair(te, make_pair(te.first + mmove[can_go[0]], te.second + moved[can_go[0]])));
						tmp.push(make_pair(to, make_pair(to.first + mmove[can_go[1]], to.second + moved[can_go[1]])));
					}
				}
			}
		}
	}
	long long white = 0;
	long long black = 0;
	long long win = 0;
	for (int i = 0;i <= n + 1;i++) {
		for (int q = 0;q <= m + 1;++q) {
			if (already_got[i][q] == 1) {
				win++;
			}
			else {
				if (choko[i][q] == 1) {
					white++;
				}
				if (choko[i][q] == 2) {
					black++;
				}
			}
		}
	}
	long long ans = win * 50;
	int hoge = min(white, black);
	ans += hoge * 10;
	ans += max(white, black) - hoge;
	cout <<ans  << endl;
	return 0;
}
0