結果
問題 | No.421 しろくろチョコレート |
ユーザー | is_eri23 |
提出日時 | 2016-09-10 00:59:39 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,156 bytes |
コンパイル時間 | 2,232 ms |
コンパイル使用メモリ | 174,236 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 19:10:35 |
合計ジャッジ時間 | 3,126 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 2 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 1 ms
5,248 KB |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 1 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | WA | - |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 2 ms
5,248 KB |
testcase_14 | AC | 2 ms
5,248 KB |
testcase_15 | AC | 2 ms
5,248 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 2 ms
5,248 KB |
testcase_20 | WA | - |
testcase_21 | AC | 3 ms
5,248 KB |
testcase_22 | WA | - |
testcase_23 | AC | 2 ms
5,248 KB |
testcase_24 | AC | 2 ms
5,248 KB |
testcase_25 | AC | 1 ms
5,248 KB |
testcase_26 | AC | 2 ms
5,248 KB |
testcase_27 | AC | 2 ms
5,248 KB |
testcase_28 | AC | 2 ms
5,248 KB |
testcase_29 | AC | 2 ms
5,248 KB |
testcase_30 | AC | 2 ms
5,248 KB |
testcase_31 | AC | 3 ms
5,248 KB |
testcase_32 | AC | 2 ms
5,248 KB |
testcase_33 | AC | 2 ms
5,248 KB |
testcase_34 | AC | 1 ms
5,248 KB |
testcase_35 | AC | 1 ms
5,248 KB |
testcase_36 | AC | 2 ms
5,248 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 2 ms
5,248 KB |
testcase_40 | WA | - |
testcase_41 | AC | 1 ms
5,248 KB |
testcase_42 | AC | 2 ms
5,248 KB |
testcase_43 | AC | 2 ms
5,248 KB |
testcase_44 | AC | 2 ms
5,248 KB |
testcase_45 | AC | 2 ms
5,248 KB |
testcase_46 | AC | 1 ms
5,248 KB |
testcase_47 | AC | 2 ms
5,248 KB |
testcase_48 | AC | 3 ms
5,248 KB |
testcase_49 | AC | 2 ms
5,248 KB |
testcase_50 | AC | 2 ms
5,248 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | AC | 2 ms
5,248 KB |
testcase_54 | AC | 2 ms
5,248 KB |
testcase_55 | AC | 2 ms
5,248 KB |
testcase_56 | AC | 2 ms
5,248 KB |
testcase_57 | WA | - |
testcase_58 | AC | 2 ms
5,248 KB |
testcase_59 | AC | 2 ms
5,248 KB |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | AC | 2 ms
5,248 KB |
testcase_63 | AC | 2 ms
5,248 KB |
testcase_64 | AC | 2 ms
5,248 KB |
ソースコード
#include <bits/stdc++.h> #define EPS 1e-9 #define INF 1070000000LL #define MOD 1000000007LL #define fir first #define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++) #define numa(x,a) for(auto x: a) #define ite iterator #define mp make_pair #define rep(i,n) rep2(i,0,n) #define rep2(i,m,n) for(int i=m;i<(n);i++) #define pb push_back #define pf push_front #define sec second #define sz(x) ((int)(x).size()) #define ALL( c ) (c).begin(), (c).end() #define gcd(a,b) __gcd(a,b) #define mem(x,n) memset(x,n,sizeof(x)) #define endl "\n" using namespace std; template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){} template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); } template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; } template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; } template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; } template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; } #define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; } #define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); } #define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); } #define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); } using ll = long long; int N,M; string bd[60]; bool used[60][60]; int dx[] = {-1,0,0,1}; int dy[] = {0,-1,1,0}; int mycount(int i, int j){ char c = 'w'; if (bd[i][j] == 'w') { c = 'b'; } int cnt = 0; rep(k,4){ int ni = i + dx[k]; int nj = j + dy[k]; if (0 <= ni && ni < N && 0 <= nj && nj < M) { if (bd[ni][nj] == c) { cnt += 1; } } } //DEBUG3(i,j,cnt); return cnt; } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> N >> M; rep(i,N){ cin >> bd[i]; } ll ans = 0; using T = pair <int, pair <int,int> >; priority_queue <T, vector <T>, greater <T> > que; rep(i,N){ rep(j,M){ if (bd[i][j] == '.') { continue; } que.push(mp(mycount(i,j), mp(i,j))); } } while(!que.empty()){ auto t = que.top(); que.pop(); int i = t.sec.fir; int j = t.sec.sec; if (used[i][j]) { continue; } //DEBUG1(t); used[i][j] = true; if (t.fir == 0 || bd[i][j] == '.') { continue; } char c = 'w'; if (bd[i][j] == 'w') { c = 'b'; } rep(k,4){ int ni = i + dx[k]; int nj = j + dy[k]; if (0 <= ni && ni < N && 0 <= nj && nj < M) { if (bd[ni][nj] == c) { //DEBUG4(i,j,ni,nj); bd[i][j] = '.'; bd[ni][nj] = '.'; rep(k2, 4){ int nni = ni + dx[k2]; int nnj = nj + dy[k2]; if (0 <= nni && nni < N && 0 <= nnj && nnj < M && bd[nni][nnj] != '.') { int nnc = mycount(nni,nnj); que.push(mp(nnc, mp(nni,nnj))); } } rep(k2, 4){ int nni = i + dx[k2]; int nnj = j + dy[k2]; if (0 <= nni && nni < N && 0 <= nnj && nnj < M && bd[nni][nnj] != '.') { int nnc = mycount(nni,nnj); que.push(mp(nnc, mp(nni,nnj))); } } ans += 100; break; } } } } map <char, int> bw; rep(i,N){ rep(j,M){ bw[bd[i][j]] += 1; } } int b = max(bw['b'], bw['w']); int w = min(bw['b'], bw['w']); cout << ans + w * 10 + (b - w) << endl; return 0; }