#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 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);}
}
}
signed 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];
//cout<<x<<" ";
}
//cout<<endl;
}
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 |
Incorrect |
3 ms |
1876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2524 ms |
2372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3026 ms |
3436 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1622 ms |
3152 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |