#include <iostream>
int a[20][20];
using namespace std;
void obojiSve(int a1, int b1, int c, int m, int n)
{
int poc=a[a1][b1];
a[a1][b1]=c;
if(a[a1+1][b1]==poc && a1<n-1)
{
obojiSve(a1+1,b1,c, m, n);
}
if(a[a1-1][b1]==poc && a1>0)
{
obojiSve(a1-1,b1,c,m,n);
}
if(a[a1][b1+1]==poc && b1<m-1)
{
obojiSve(a1,b1+1,c,m,n);
}
if(a[a1][b1-1]==poc && b1>0)
{
obojiSve(a1,b1-1,c,m,n);
}
}
int main()
{
int n,m;
cin>>n>>m;
for(int i=0; i<n; i++)
{
for(int j=0; j<m; j++)
{
cin>>a[i][j];
}
}
int q,a1,b1,c;
cin>>q;
for(int k=0; k<q; k++)
{
cin>>a1>>b1>>c;
a1--;b1--;
obojiSve(a1,b1,c,m,n);
}
for(int i=0; i<n; i++)
{
for(int j=0; j<m; j++)
{
cout<<a[i][j]<<' ';
}
cout<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
269 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
332 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |