結果

問題 No.307 最近色塗る問題多くない?
ユーザー kotatsugamekotatsugame
提出日時 2019-10-14 03:54:05
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 783 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 74,356 KB
実行使用メモリ 7,860 KB
最終ジャッジ日時 2023-08-23 11:02:00
合計ジャッジ時間 7,209 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 325 ms
4,376 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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<queue>
using namespace std;
int used[200][200];
int A[200][200];
int H,W;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
main()
{
	cin>>H>>W;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin>>A[i][j];
	int Q;cin>>Q;
	for(int t=0;t++<Q;)
	{
		int r,c,x;cin>>r>>c>>x;r--,c--;
		int y=A[r][c];
		if(x==y)continue;
		A[r][c]=x;
		queue<pair<int,int> >P;
		P.push(make_pair(r,c));
		used[r][c]=t;
		while(!P.empty())
		{
			int nx=P.front().first,ny=P.front().second;P.pop();
			for(int R=0;R<4;R++)
			{
				int tx=nx+dx[R],ty=ny+dy[R];
				if(tx>=0&&ty>=0&&tx<H&&ty<W&&used[tx][ty]<t&&A[tx][ty]==y)
				{
					A[tx][ty]=x;
					used[tx][ty]=t;
					P.push(make_pair(tx,ty));
				}
			}
		}
	}
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)cout<<A[i][j]<<(j==W-1?"\n":" ");
}
0