답안 #775667

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775667 2023-07-06T18:06:12 Z DangerNoodle7591 Paint (COI20_paint) C++17
8 / 100
3000 ms 3136 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define endl "\n"
#define ll long long
#define N 200005
int var[N],renk[N];
int n,m;
void bfs(int x,int co,int mor){
	queue<int> q;
	q.push(x);
	while(q.size()){
		int a=q.front();q.pop();
		if(var[a])continue;
		var[a]=1;
		renk[a]=mor;
		if((a-1)%m&&var[a-1]==0&&renk[a-1]==co){q.push(a-1);}
		
		if(a%m&&var[a+1]==0&&renk[a+1]==co){q.push(a+1);}
		
		if(a-m>0&&var[a-m]==0&&renk[a-m]==co){q.push(a-m);}

		if(a+m<=n*m&&var[a+m]==0&&renk[a+m]==co){q.push(a+m);}
	}
}
int main(){
	lalala;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int x=(i-1)*m+j;
			cin>>renk[x];
		}
	}
	int q;cin>>q;
	while(q--){
		int x,yyy,mor;cin>>x>>yyy>>mor;
		x=(x-1)*m+yyy;
		bfs(x,renk[x],mor);
		memset(var,0,sizeof(var));

	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int x=(i-1)*m+j;
			cout<<renk[x]<<" ";
		}cout<<endl;
	}
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1108 KB Output is correct
2 Correct 3 ms 1108 KB Output is correct
3 Correct 59 ms 1228 KB Output is correct
4 Correct 82 ms 1196 KB Output is correct
5 Correct 334 ms 1236 KB Output is correct
6 Correct 443 ms 1196 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1141 ms 1284 KB Output is correct
2 Correct 1280 ms 1672 KB Output is correct
3 Execution timed out 3064 ms 1832 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2949 ms 2256 KB Output is correct
2 Correct 739 ms 2788 KB Output is correct
3 Correct 902 ms 2724 KB Output is correct
4 Execution timed out 3068 ms 2608 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 759 ms 1920 KB Output is correct
2 Execution timed out 3072 ms 3136 KB Time limit exceeded
3 Halted 0 ms 0 KB -