Submission #1003907

# Submission time Handle Problem Language Result Execution time Memory
1003907 2024-06-20T19:47:48 Z vjudge1 Paint (COI20_paint) C++17
8 / 100
3000 ms 16272 KB
#include<bits/stdc++.h>

using namespace std;

vector <vector <int>> v;
int r, s;
	
bool check(int a, int b){
	return (a >= 0 and a < r and b >= 0 and b < s);
}
void dfs(int a, int b, int cor1, int cor2){
	if(v[a][b] == cor1) v[a][b] = cor2;
	else return;
	if(check(a-1, b)) dfs(a-1, b, cor1, cor2);
	if(check(a+1, b)) dfs(a+1, b, cor1, cor2);
	if(check(a, b-1)) dfs(a, b-1, cor1, cor2);
	if(check(a, b+1)) dfs(a, b+1, cor1, cor2);
	return;
}

int main(){
	cin >> r >> s;
	for(int i = 0;i < r;i++){
		vector <int> aux;
		for(int i = 0;i < s;i++){
			int x;
			cin >> x;
			aux.push_back(x);
		}
		v.push_back(aux);
	}
	int q;
	cin >> q;
	while(q--){
		int l, r, cor;
		cin >> l >> r >> cor;
		l--;
		r--;
		if(v[l][r] == cor) continue;
		dfs(l, r, v[l][r], cor);
	}
	for(auto x : v){
		for(auto y : x){
			cout << y << ' ';
		}
		cout << endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
5 Correct 277 ms 852 KB Output is correct
6 Correct 573 ms 1360 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 768 KB Output is correct
2 Correct 108 ms 2364 KB Output is correct
3 Execution timed out 3062 ms 8652 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2347 ms 16272 KB Output is correct
2 Correct 427 ms 10832 KB Output is correct
3 Correct 506 ms 12372 KB Output is correct
4 Execution timed out 3082 ms 10228 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 112 ms 3572 KB Output is correct
2 Execution timed out 3016 ms 8096 KB Time limit exceeded
3 Halted 0 ms 0 KB -