#include<iostream>
using namespace std;
int field[201][201];
int main(){
cin.tie(NULL);
ios::sync_with_stdio(false);
int n,m,k;
cin>>n>>m>>k;
for(int i=0;i<k;i++){
int x,y,t,hor=1,ver=1,cntHor=1,cntVer=1,type=0;
cin>>x>>y>>t;
x+=n;
y+=m;
int cnt=1;
while(x>0&&y>0&&x<=3*n&&y<=3*m){
if(field[x][y]==0) field[x][y]=1<<30;
field[x][y]=min(field[x][y],cnt);
if(type==0){
x--;
cntVer--;
}
if(type==2){
x++;
cntVer--;
}
if(type==1){
if(t==0){
y++;
}else{
y--;
}
cntHor--;
}
if(type==3){
if(t==0){
y--;
}else{
y++;
}
cntHor--;
}
if(cntVer==0){
ver++;
cntVer=ver;
type++;
}
if(cntHor==0){
hor++;
cntHor=hor;
type++;
type%=4;
}
cnt++;
}
}
for(int i=n+1;i<=2*n;i++){
for(int j=m+1;j<=2*m;j++){
cout<<field[i][j]<<" ";
}
cout<<"\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
2 ms |
484 KB |
Output is correct |
5 |
Correct |
2 ms |
548 KB |
Output is correct |
6 |
Correct |
2 ms |
608 KB |
Output is correct |
7 |
Correct |
2 ms |
628 KB |
Output is correct |
8 |
Correct |
2 ms |
648 KB |
Output is correct |
9 |
Correct |
148 ms |
800 KB |
Output is correct |
10 |
Correct |
2 ms |
820 KB |
Output is correct |