結果

問題 No.307 最近色塗る問題多くない?
ユーザー IL_mstaIL_msta
提出日時 2018-02-16 20:17:58
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,967 bytes
コンパイル時間 1,085 ms
コンパイル使用メモリ 103,352 KB
実行使用メモリ 8,756 KB
最終ジャッジ日時 2023-09-03 23:10:34
合計ジャッジ時間 7,640 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
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 #

#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
//#include <intrin.h>
#include <ctime>
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

int H,W;
vector< vector<int> > field;
void solve(){
	cin >> H >> W;
	field = vector< vector<int> >(H+2,vector<int>(W+2,4));
	for(int h=0;h<H;++h){
		for(int w=0;w<W;++w){
			cin >> field[h+1][w+1];
		}
	}
	int Q;
	cin >> Q;
	int R,C,X;
	queue<int> posQ;
	vector<int> dir(4);
	dir[0] = 1;
	dir[1] = W+2;
	dir[2] = -1;
	dir[3] = -(W+2);
	int now;
	while(Q--){
		cin >> R >> C >> X;
		if( field[R][C] == X ) continue;
		int chang = field[R][C];
		field[R][C] = X;

		posQ.push( R*(W+2)+C);
		while(posQ.size()){
			now = posQ.front();
			posQ.pop();
			for(int k=0;k<4;++k){
				int temp = now + dir[k];
				int r = temp/(W+2);
				int c = temp%(W+2);
				if( field[r][c] == chang ){
					field[r][c] = X;
					posQ.push( temp );
				}
			}
		}
	}
	for(int h=0;h<H;++h){
		for(int w=0;w<W;++w){
			cout << field[h+1][w+1];
		}
		cout << endl;
	}
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()
0