結果
| 問題 |
No.307 最近色塗る問題多くない?
|
| コンテスト | |
| ユーザー |
rickytheta
|
| 提出日時 | 2015-11-28 21:41:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,462 bytes |
| コンパイル時間 | 1,264 ms |
| コンパイル使用メモリ | 161,012 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 04:59:43 |
| 合計ジャッジ時間 | 5,944 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
int h,w;
int mp[200][200];
int nxt[200][200];
bool used[200][200];
int vx[4] = {1,0,-1,0};
int vy[4] = {0,1,0,-1};
void dfs(int y,int x,int col){
if(x<0 || y<0 || x>=w || y>=h)return;
if(used[y][x])return;
used[y][x] = true;
if(mp[y][x] == col)return;
nxt[y][x] = col;
REP(i,4){
dfs(y+vy[i],x+vx[i],col);
}
}
int main(){
cin >> h >> w;
// vector<vi> mp(h,vi(w));
REP(i,h)REP(j,w){
cin>>mp[i][j];
nxt[i][j] = mp[i][j];
}
int q;
cin >> q;
REP(_,q){
int y,x,col;
cin >> y >> x >> col;
--y;--x;
fill(used[0],used[200],false);
dfs(y,x,col);
if(used[0][0] && used[h-1][0] && used[0][w-1] && used[h-1][w-1]){
REP(t,q-1-_){
cin >> y >> x >> col;
}
fill(mp[0],mp[200],col);
break;
}
REP(i,h)REP(j,w)mp[i][j]=nxt[i][j];
}
REP(i,h){
cout << mp[i][0];
REPR(j,w) cout << " " << mp[i][j];
cout << endl;
}
return 0;
}
rickytheta