結果
問題 | No.2946 Puyo |
ユーザー | hibit_at |
提出日時 | 2024-10-25 22:18:19 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 202 ms / 2,000 ms |
コード長 | 5,270 bytes |
コンパイル時間 | 1,616 ms |
コンパイル使用メモリ | 129,824 KB |
実行使用メモリ | 38,656 KB |
最終ジャッジ日時 | 2024-10-25 22:18:28 |
合計ジャッジ時間 | 8,020 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 166 ms
8,448 KB |
testcase_04 | AC | 165 ms
8,576 KB |
testcase_05 | AC | 158 ms
8,576 KB |
testcase_06 | AC | 162 ms
8,576 KB |
testcase_07 | AC | 161 ms
8,576 KB |
testcase_08 | AC | 13 ms
6,816 KB |
testcase_09 | AC | 54 ms
6,816 KB |
testcase_10 | AC | 12 ms
6,820 KB |
testcase_11 | AC | 85 ms
6,816 KB |
testcase_12 | AC | 13 ms
6,820 KB |
testcase_13 | AC | 2 ms
6,816 KB |
testcase_14 | AC | 20 ms
6,816 KB |
testcase_15 | AC | 10 ms
6,820 KB |
testcase_16 | AC | 30 ms
6,816 KB |
testcase_17 | AC | 97 ms
6,820 KB |
testcase_18 | AC | 4 ms
6,816 KB |
testcase_19 | AC | 41 ms
6,816 KB |
testcase_20 | AC | 55 ms
6,820 KB |
testcase_21 | AC | 90 ms
6,816 KB |
testcase_22 | AC | 13 ms
6,820 KB |
testcase_23 | AC | 52 ms
6,816 KB |
testcase_24 | AC | 119 ms
6,816 KB |
testcase_25 | AC | 109 ms
6,820 KB |
testcase_26 | AC | 121 ms
6,816 KB |
testcase_27 | AC | 4 ms
6,816 KB |
testcase_28 | AC | 122 ms
16,768 KB |
testcase_29 | AC | 175 ms
16,000 KB |
testcase_30 | AC | 89 ms
11,904 KB |
testcase_31 | AC | 135 ms
16,512 KB |
testcase_32 | AC | 110 ms
9,216 KB |
testcase_33 | AC | 86 ms
6,816 KB |
testcase_34 | AC | 125 ms
9,472 KB |
testcase_35 | AC | 99 ms
7,552 KB |
testcase_36 | AC | 102 ms
8,576 KB |
testcase_37 | AC | 105 ms
7,936 KB |
testcase_38 | AC | 75 ms
6,820 KB |
testcase_39 | AC | 71 ms
6,816 KB |
testcase_40 | AC | 48 ms
6,820 KB |
testcase_41 | AC | 97 ms
6,820 KB |
testcase_42 | AC | 89 ms
6,816 KB |
testcase_43 | AC | 152 ms
29,312 KB |
testcase_44 | AC | 202 ms
38,656 KB |
testcase_45 | AC | 144 ms
20,864 KB |
testcase_46 | AC | 70 ms
7,808 KB |
testcase_47 | AC | 103 ms
10,752 KB |
ソースコード
#include <algorithm> #include <iostream> #include <iomanip> #include <limits.h> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <utility> #include <vector> #include <stack> #include <complex> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n + 1; i++) #define rev(i, n) for (int i = n - 1; i >= 0; i--) #define all(A) A.begin(), A.end() #define itr(A, l, r) A.begin() + l, A.begin() + r #define debug(var) cout << #var << " = " << var << endl; typedef long long ll; template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (int i = 0; i < (int)v.size(); i++) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; } template <typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { for (int i = 0; i < (int)v.size(); i++) { os << v[i] << endl; } return os; } template <typename T> ostream &operator<<(ostream &os, const vector<vector<vector<T>>> &v) { int n = v.size(); int m = v[0].size(); int p = v[0][0].size(); rep(k, p) { os << "k = " << k << endl; rep(i, n) { rep(j, m) { os << v[i][j][k]; if (j < m - 1) { os << " "; } else { os << endl; } } } } return os; } template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; } template <typename T, typename S> ostream &operator<<(ostream &os, map<T, S> &mp) { for (auto &[key, val] : mp) { os << key << ":" << val << " "; } cout << endl; return os; } template <typename T> ostream &operator<<(ostream &os, set<T> st) { auto itr = st.begin(); for (int i = 0; i < (int)st.size(); i++) { os << *itr << (i + 1 != (int)st.size() ? " " : ""); itr++; } return os; } template <typename T> ostream &operator<<(ostream &os, multiset<T> st) { auto itr = st.begin(); for (int i = 0; i < (int)st.size(); i++) { os << *itr << (i + 1 != (int)st.size() ? " " : ""); itr++; } return os; } template <typename T> ostream &operator<<(ostream &os, queue<T> q) { while (q.size()) { os << q.front() << " "; q.pop(); } return os; } template <typename T> ostream &operator<<(ostream &os, deque<T> q) { while (q.size()) { os << q.front() << " "; q.pop_front(); } return os; } template <typename T> ostream &operator<<(ostream &os, stack<T> st) { while (st.size()) { os << st.top() << " "; st.pop(); } return os; } template <typename T> ostream &operator<<(ostream &os, priority_queue<T> pq) { while (pq.size()) { os << pq.top() << " "; pq.pop(); } return os; } template <typename T> ostream &operator<<(ostream &os, priority_queue<T, vector<T>, greater<T>> mpq) { while (mpq.size()) { os << mpq.top() << " "; mpq.pop(); } return os; } int main(){ int h,w; cin >> h >> w; vector<vector<char>> maze(h,vector<char>(w)); cin >> maze; // cout << maze << endl; vector<vector<bool>> seen(h,vector<bool>(w)); vector<vector<int>> dist(h,vector<int>(w)); rep(i,h){ rep(j,w){ if(seen[i][j]){ continue; } vector<int> dx = {1,-1,0,0}; vector<int> dy = {0,0,1,-1}; set<pair<int,int>> st; seen[i][j] = true; st.insert({i,j}); char head = maze[i][j]; auto dfs = [&](auto dfs, int cx,int cy)->int{ int ans = 1; rep(k,4){ int nx = cx + dx[k]; int ny = cy + dy[k]; if(nx<0 || h<=nx){ continue; } if(ny<0 || w<=ny){ continue; } if(seen[nx][ny]){ continue; } if(maze[nx][ny] != head){ continue; } seen[nx][ny] = true; st.insert({nx,ny}); ans += dfs(dfs,nx,ny); } return ans; }; int tmp = dfs(dfs,i,j); // debug(tmp); if(tmp >= 4){ for(auto [cx,cy] : st){ maze[cx][cy] = '.'; } } } } // cout << maze << endl; for(auto &ans : maze){ for(auto a : ans){ cout << a; } cout << endl; } }