Submission #649873

#TimeUsernameProblemLanguageResultExecution timeMemory
649873inksamuraiBirokracija (COCI18_birokracija)C++17
0 / 100
1098 ms3028 KiB
#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]; 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; while(1){ 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)){ 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...