結果

問題 No.307 最近色塗る問題多くない?
ユーザー kurenaifkurenaif
提出日時 2016-03-01 22:52:51
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,968 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 80,232 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2023-10-24 19:24:51
合計ジャッジ時間 7,034 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 719 ms
4,348 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 <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <limits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <bitset>
#include <iomanip>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };

queue<pair<int, int> > sel;

int A[204][204];
void select(int i, int j,int x) {
	sel.push(MP(i,j));
	for (int c = 0; c < 4; ++c) {
		if (A[i + dy[c]][j + dx[c]] == x) {
			A[i + dy[c]][j + dx[c]] = -2;
			select(i + dy[c], j + dx[c], x);
		}
	}
}

int main(void) {
	int H, W;
	memset(A, -1, sizeof(A));

	cin >> H >> W;
	for (int h = 1; h <= H; ++h) {
		for (int w = 1; w <= W; ++w) {
			cin >> A[h][w];
		}
	}
	int Q; cin >> Q;

	for (int count = 0; count < Q; ++count) {
		int R, C, X;
		cin >> R >> C >> X;
		select(R, C, A[R][C]);
		while (!sel.empty()) {
			auto a = sel.front(); sel.pop();
			A[a.first][a.second] = X;
		}
	}

	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			cout << A[i][j];
			if (j != W) cout << " ";
		}
		cout << endl;
	}
	return 0;
}
0