結果
問題 |
No.421 しろくろチョコレート
|
ユーザー |
![]() |
提出日時 | 2016-09-10 00:38:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,801 bytes |
コンパイル時間 | 907 ms |
コンパイル使用メモリ | 94,332 KB |
実行使用メモリ | 7,756 KB |
最終ジャッジ日時 | 2024-11-16 19:06:45 |
合計ジャッジ時間 | 2,490 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 WA * 40 |
ソースコード
#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 = 0;i <= n+1;++i) { for (int q = 0;q <= m+1;++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]] = true; 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; }