結果

問題 No.307 最近色塗る問題多くない?
ユーザー treeonetreeone
提出日時 2016-05-02 22:55:59
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 936 bytes
コンパイル時間 1,997 ms
コンパイル使用メモリ 159,228 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-15 09:25:32
合計ジャッジ時間 8,417 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
12,960 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 428 ms
6,944 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int a[210][210];
int dy[4]={1,-1,0,0};
int dx[4]={0,0,1,-1};
int h,w,q;
bool f[210][210];

void dfs(int r,int c,int color,int x){
	f[r][c]=true;
	a[r][c]=x;
	rep(i,0,4){
		int ny=r+dy[i];
		int nx=c+dx[i];
		if(0<=ny && ny<h && 0<=nx && nx<w && a[ny][nx]==color && f[ny][nx]==false){
			dfs(ny,nx,color,x);
		}
	}
	return;
}

signed main(){
	cin>>h>>w;
	rep(i,0,h) rep(j,0,w) cin>>a[i][j];
	cin>>q;
	rep(i,0,q){
		int r,c,x;
		cin>>r>>c>>x;
		r--; c--;
		int color=a[r][c];
		rep(i,0,h) rep(j,0,w) f[i][j]=false;
		dfs(r,c,color,x);
	}
	rep(i,0,h){
		rep(j,0,w){
			cout<<(j?" ":"")<<a[i][j];
		}
		cout<<endl;
	}
}
0