Submission #649880

# Submission time Handle Problem Language Result Execution time Memory
649880 2022-10-11T13:56:21 Z inksamurai Spirale (COCI18_spirale) C++17
32 / 80
1000 ms 2304 KB
#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){
			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 Correct 1 ms 2260 KB Output is correct
5 Correct 2 ms 2260 KB Output is correct
6 Correct 15 ms 2304 KB Output is correct
7 Correct 2 ms 2260 KB Output is correct
8 Incorrect 2 ms 2260 KB Output isn't correct
9 Execution timed out 1088 ms 2260 KB Time limit exceeded
10 Incorrect 41 ms 2304 KB Output isn't correct