結果
| 問題 | No.3730 Jagged Minesweeper |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-07-22 03:54:54 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 74 ms / 2,500 ms |
| + 163µs | |
| コード長 | 1,427 bytes |
| 記録 | |
| コンパイル時間 | 3,181 ms |
| コンパイル使用メモリ | 361,012 KB |
| 実行使用メモリ | 11,776 KB |
| 最終ジャッジ日時 | 2026-09-19 12:35:21 |
| 合計ジャッジ時間 | 9,600 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 43 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
if (!(cin >> n)) return 0;
vector<string> a(n);
for (string& row : a) cin >> row;
const int di[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dj[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int v = n * n;
vector<unsigned char> bomb(v, 0), neighbours(v, 0);
queue<int> que;
vector<unsigned char> queued(v, 1);
for (int id = 0; id < v; ++id) que.push(id);
auto enqueue = [&](int id) {
if (!queued[id]) {
queued[id] = 1;
que.push(id);
}
};
while (!que.empty()) {
int id = que.front();
que.pop();
queued[id] = 0;
int i = id / n, j = id % n;
bool should_be_bomb = neighbours[id] < a[i][j] - '0';
if (bomb[id] == should_be_bomb) continue;
int delta = should_be_bomb ? 1 : -1;
bomb[id] = should_be_bomb;
for (int d = 0; d < 8; ++d) {
int ni = i + di[d], nj = j + dj[d];
if (ni < 0 || ni >= n || nj < 0 || nj >= n) continue;
int nid = ni * n + nj;
neighbours[nid] += delta;
enqueue(nid);
}
}
string row(n, '.');
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) row[j] = bomb[i * n + j] ? 'o' : '.';
cout << row << '\n';
}
return 0;
}