結果
| 問題 |
No.2946 Puyo
|
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2024-10-27 00:18:25 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 339 ms / 2,000 ms |
| コード長 | 1,145 bytes |
| コンパイル時間 | 3,507 ms |
| コンパイル使用メモリ | 260,968 KB |
| 実行使用メモリ | 11,904 KB |
| 最終ジャッジ日時 | 2024-10-27 00:18:38 |
| 合計ジャッジ時間 | 12,058 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "settings/debug.cpp"
#else
#define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
int h, w;
cin >> h >> w;
vector Grid(h, vector<char>(w));
rep(i, h) rep(j, w) cin >> Grid[i][j];
rep(i, h) rep(j, w) {
if (Grid[i][j] == '.') continue;
queue<pair<int, int>> q;
set<pair<int, int>> cc;
q.push({ i, j });
cc.insert({ i, j });
constexpr array<int, 4> dx = { 0, 1, 0, -1 };
constexpr array<int, 4> dy = { 1, 0, -1, 0 };
while (!q.empty()) {
auto [x, y] = q.front();
q.pop();
rep(d, 4) {
int nx = x + dx[d], ny = y + dy[d];
if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
if (Grid[nx][ny] == Grid[i][j]) {
if (cc.contains({ nx, ny })) continue;
q.push({ nx, ny });
cc.insert({ nx, ny });
}
}
}
if (cc.size() >= 4) for (auto [x, y] : cc) Grid[x][y] = '.';
}
rep(i, h) {
rep(j, w) cout << Grid[i][j];
cout << endl;
}
return 0;
}
a01sa01to