Submission #773836

# Submission time Handle Problem Language Result Execution time Memory
773836 2023-07-05T09:00:52 Z vjudge1 Paint (COI20_paint) C++17
0 / 100
224 ms 524288 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define N 10005
int var[N][N],renk[N][N];
int n,m;
void bfs(int x,int y,int co,int mor){
	queue<pair<int,int>> q;
	q.push({x,y});
	while(q.size()){
		int a=q.front().first,b=q.front().second;q.pop();
		if(var[a][b])continue;
		var[a][b]=1;
		renk[a][b]=mor;
		if(a-1>0&&var[a-1][b]==0&&renk[a-1][b]==co){q.push({a-1,b});}
		
		if(a+1<=n&&var[a+1][b]==0&&renk[a+1][b]==co){q.push({a+1,b});}
		
		if(b-1>0&&var[a][b-1]==0&&renk[a][b-1]==co){q.push({a,b-1});}

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

	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cout<<renk[i][j];
		}cout<<endl;
	}
	
}
# Verdict Execution time Memory Grader output
1 Runtime error 183 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 189 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 224 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 169 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -