結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 3 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 8 ms
4,348 KB
testcase_08 AC 43 ms
6,816 KB
testcase_09 AC 14 ms
5,400 KB
testcase_10 AC 261 ms
4,348 KB
testcase_11 AC 1,802 ms
5,048 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 24 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 16 ms
5,200 KB
testcase_18 AC 43 ms
6,268 KB
testcase_19 AC 37 ms
6,356 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 40 ms
5,836 KB
testcase_22 AC 34 ms
6,912 KB
testcase_23 AC 195 ms
6,984 KB
testcase_24 AC 76 ms
5,700 KB
testcase_25 AC 128 ms
6,944 KB
testcase_26 AC 235 ms
7,076 KB
testcase_27 AC 23 ms
4,348 KB
testcase_28 WA -
testcase_29 AC 17 ms
4,348 KB
testcase_30 AC 239 ms
7,168 KB
testcase_31 AC 40 ms
4,348 KB
testcase_32 AC 40 ms
4,348 KB
testcase_33 AC 16 ms
7,164 KB
testcase_34 TLE -
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;

	bool isEnd = false;
	for (int count = 0; count < Q; ++count) {
		int R, C, X;
		cin >> R >> C >> X;
		select(R, C, A[R][C]);
		if (sel.size() >= H*W) {
			++count;
			for (; count < Q; ++count) {
				cin >> R >> C >> X;
			}
		}
		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