# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1003951 |
2024-06-20T20:46:50 Z |
vjudge1 |
Paint (COI20_paint) |
C++17 |
|
25 ms |
4700 KB |
#include<bits/stdc++.h>
using namespace std;
const int MAXN=10010;
vector <int> v[MAXN],mark[MAXN];
int r, s;
void dfs(int x, int y, int cor){
mark[x][y] = 1;
if(x+1<=s && v[x+1][y]==v[x][y] && mark[x+1][y]==0) dfs(x+1, y, cor);
if(x-1>0 && v[x-1][y]==v[x][y] && mark[x-1][y]==0) dfs(x-1, y, cor);
if(y+1<=r && v[x][y+1]==v[x][y] && mark[x][y+1]==0) dfs(x, y+1, cor);
if(y-1>0 && v[x][y-1]==v[x][y] && mark[x][y-1]==0) dfs(x, y-1, cor);
v[x][y] = cor;
}
int main(){
cin >> r >> s;
for(int i=1; i<=r; i++){
v[i].push_back(0);
for(int j=1; j<=s; j++){
int x;
cin >> x;
v[i].push_back(x);
}
}
/*
for(int i=1; i<=r; i++){
for(int j=1; j<=s; j++) cout << v[i][j] << " ";
cout << endl;
}
*/
int q;
cin >> q;
for(int i=1; i<=r; i++){
for(int j=0; j<=s; j++){
mark[i].push_back(0);
}
}
for(int i=0; i<q; i++){
int x, y, cor;
cin >> x >> y >> cor;
for(int j=1; j<=r; j++){
for(int k=1; k<=s; k++){
mark[j][k] = 0;
}
}
dfs(x, y, cor);
}
for(int i=1; i<=r; i++){
for(int j=1; j<=s; j++){
cout << v[i][j] << " ";
}
cout << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
1372 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
2392 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
25 ms |
4700 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
19 ms |
3932 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |