結果
| 問題 | No.3730 Jagged Minesweeper |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2026-09-21 16:01:36 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 126 ms / 2,500 ms |
| + 16µs | |
| コード長 | 1,317 bytes |
| 記録 | |
| コンパイル時間 | 363 ms |
| コンパイル使用メモリ | 77,396 KB |
| 実行使用メモリ | 61,176 KB |
| 最終ジャッジ日時 | 2026-09-21 16:01:47 |
| 合計ジャッジ時間 | 9,203 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 43 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 3730.cc: No.3730 Jagged Minesweeper - yukicoder
*/
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 1000;
const int MAX_NN = MAX_N * MAX_N;
const int dxs[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dys[] = {0, -1, -1, -1, 0, 1, 1, 1};
/* typedef */
using qi = queue<int>;
/* global variables */
char s[MAX_N + 4];
int as[MAX_NN], cs[MAX_NN];
bool fs[MAX_NN];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0, u = 0; i < n; i++) {
scanf("%s", s);
for (int j = 0; j < n; j++) as[u++] = s[j] - '0';
}
int nn = n * n;
qi q;
for (int u = 0; u < nn; u++) q.push(u);
while (! q.empty()) {
int u = q.front(); q.pop();
int dc = 0;
if (! fs[u] && cs[u] < as[u])
fs[u] = true, dc = 1;
else if (fs[u] && cs[u] >= as[u])
fs[u] = false, dc = -1;
if (dc != 0) {
int uy = u / n, ux = u % n;
for (int di = 0; di < 8; di++) {
int vy = uy + dys[di], vx = ux + dxs[di], v = vy * n + vx;
if (vy >= 0 && vy < n && vx >= 0 && vx < n) {
cs[v] += dc;
q.push(v);
}
}
}
}
for (int i = 0, u = 0; i < n; i++) {
for (int j = 0; j < n; j++, u++) putchar(fs[u] ? 'o' : '.');
putchar('\n');
}
return 0;
}
tnakao0123