結果
問題 |
No.2946 Puyo
|
ユーザー |
|
提出日時 | 2024-10-26 20:49:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 1,171 bytes |
コンパイル時間 | 2,237 ms |
コンパイル使用メモリ | 204,924 KB |
最終ジャッジ日時 | 2025-02-25 00:32:25 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
#include <bits/stdc++.h> using namespace std; template<class T> istream& operator >> (istream& is, vector<T>& vec) { for(T& x : vec) is >> x; return is; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int h, w; cin >> h >> w; vector<string> A(h); cin >> A; vector B(h, vector<bool>(w)); vector<pair<int,int>> vec; for(int y = 0; y < h; y++){ for(int x = 0; x < w; x++){ if(B[y][x]) continue; vec.clear(); B[y][x] = true; vec.emplace_back(y, x); for(int i = 0; i < vec.size(); i++){ auto [cy, cx] = vec[i]; for(int i = 0; i < 4; i++){ int ny = cy + (i == 0) - (i == 1); int nx = cx + (i == 2) - (i == 3); if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue; if(A[y][x] != A[ny][nx] || B[ny][nx]) continue; B[ny][nx] = true; vec.emplace_back(ny, nx); } } if(vec.size() >= 4) for(auto [y, x] : vec) A[y][x] = '.'; } cout << A[y] << '\n'; } }