結果
| 問題 |
No.421 しろくろチョコレート
|
| ユーザー |
|
| 提出日時 | 2016-09-09 23:29:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,459 bytes |
| コンパイル時間 | 1,808 ms |
| コンパイル使用メモリ | 173,068 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-16 18:40:47 |
| 合計ジャッジ時間 | 2,970 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 51 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x) cerr << #x << " = " << (x) << endl
using namespace std;
// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5
char field[55][55];
int H, W;
struct Point {
int x, y, cnt;
};
ll grid_bfs(int y,int x) {
int i, j;
Point s;
s.cnt = 0;
//............
s.y = y;
s.x = x;
//..............
queue<Point> q;
q.push(s);
field[s.y][s.x] = '.';
ll cnt = 1;
while (q.size()) {
auto now = q.front(); q.pop();
Point next = now;
rep(i, 4) {
next.x = now.x + dx[i];
next.y = now.y + dy[i];
if (next.x < 0 || W <= next.x) continue;
if (next.y < 0 || H <= next.y) continue;
if (field[next.y][next.x] == '.') continue;
field[next.y][next.x] = '.';
cnt++;
q.push(next);
}
}
return cnt;
}
signed main(void) {
ll i, j, k, l;
cin >> H >> W;
rep(i, H) rep(j, W) {
cin >> field[i][j];
}
ll rest = 0;
ll ans = 0;
rep(i, H) rep(j, W) {
if (field[i][j] != '.') {
ll a = grid_bfs(i, j);
ans += a / 2 * 100;
rest += a % 2;
}
}
ans += rest / 2 * 10;
ans += rest % 2;
cout << ans << endl;
return 0;
}