結果
| 問題 |
No.307 最近色塗る問題多くない?
|
| コンテスト | |
| ユーザー |
iqueue02
|
| 提出日時 | 2020-01-15 22:53:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 944 bytes |
| コンパイル時間 | 2,195 ms |
| コンパイル使用メモリ | 177,064 KB |
| 実行使用メモリ | 14,016 KB |
| 最終ジャッジ日時 | 2024-06-12 04:08:30 |
| 合計ジャッジ時間 | 14,421 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 TLE * 2 -- * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int main(){
int h, w;
cin >> h >> w;
vector<vector<int>> a(h, vector<int>(w));
rep(i,h) rep(j,w) cin >> a[i][j];
int q;
cin >> q;
while (q--) {
int r, c, x;
cin >> r >> c >> x;
r--; c--;
if (a[r][c] == x) continue;
queue<P> que;
que.push(make_pair(r, c));
a[r][c] = x;
while (!que.empty()) {
auto p = que.front(); que.pop();
for (int i = 0; i < 4; i++) {
int nx = p.first + dx[i], ny = p.second + dy[i];
if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
if (a[nx][ny] == x) continue;
a[nx][ny] = x;
que.push(make_pair(nx,ny));
}
}
}
rep(i,h) {
rep(j,w) cout << a[i][j] << " ";
cout << endl;
}
return 0;
}
iqueue02