#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _3yqVz8E ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
using pii=pair<int,int>;
using vi=vector<int>;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}
// e
const int _n=711,inf=1e9;
int a[_n][_n];
int tbl[_n][_n][4];
void gap(){
rep(i,_n)rep(j,_n)a[i][j]=inf;
}
int h,w,n;
bool contains(){
rep(i,h){
rep(j,w){
if(a[i][j]==-1)return 1;
}
}
return 0;
}
const int di[]={-1,0,1,0};
const int dj[]={0,1,0,-1};
const int di1[]={-1,0,1,0};
const int dj1[]={0,-1,0,1};
bool ok(int x,int y){
return x>=0 and y>=0 and x<h and y<w;
}
signed main(){
_3yqVz8E;
gap();
cin>>h>>w>>n;
rep(i,n){
vi usd(h*w);
int sx,sy,t;
cin>>sx>>sy>>t;
sx-=1,sy-=1;
a[sx][sy]=1;
usd[sx*w+sy]=1;
int _last=1;
int ai=1;
int now=0,cnt=0;
int dir=0;
rep(_,h*w/4){
bool pok=0;
rep(i,h)rep(j,w)if(!usd[i*w+j])pok=1;
if(!pok) break;
ai+=1;
if(!t) sx+=di[dir];
else sx+=di1[dir];
if(!t) sy+=dj[dir];
else sy+=dj1[dir];
if(ok(sx,sy)){
// if(tbl[sx][sy][dir]<ai) break;
// tbl[sx][sy][dir]=ai;
usd[sx*w+sy]=1;
a[sx][sy]=min(a[sx][sy],ai);
}
now+=1;
if(now==_last){
now=0;
dir++;
dir%=4;
cnt+=1;
if(cnt==2){
cnt=0;
_last+=1;
}
}
}
}
rep(i,h){
rep(j,w){
cout<<a[i][j]<<" ";
}
cout<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2260 KB |
Output isn't correct |
2 |
Incorrect |
2 ms |
2260 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
2260 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
2260 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
2300 KB |
Output isn't correct |
6 |
Incorrect |
5 ms |
2260 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
2260 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
2260 KB |
Output isn't correct |
9 |
Execution timed out |
1099 ms |
2260 KB |
Time limit exceeded |
10 |
Incorrect |
8 ms |
2308 KB |
Output isn't correct |