Submission #49828

#TimeUsernameProblemLanguageResultExecution timeMemory
49828A_H_GhaznaviSpirale (COCI18_spirale)C++14
64 / 80
215 ms764 KiB
// In the name of god // A.H.Ghaznavi #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=60; int m,n,k,x,y,t,l,c,table[maxn][maxn],d,tab; char rec[5]; void doing (char ch,int in) { if (ch=='U') { for (int i=1;i<=in;i++) { if (l-i>=1 && (table[l-i][c]==-1 || tab<table[l-i][c]) && l-i<=n && c>=1 && c<=m) table[l-i][c]=tab; tab++; } l-=in; } if (ch=='D') { for (int i=1;i<=in;i++) { if (l+i<=n && (table[l+i][c]==-1 || tab<table[l+i][c]) && c>=1 && c<=m && l+i>=1) table[l+i][c]=tab; tab++; } l+=in; } if (ch=='L') { for (int i=1;i<=in;i++) { if (c-i>=1 && (table[l][c-i]==-1 || tab<table[l][c-i]) && l>=1 && l<=n && c-i<=m) table[l][c-i]=tab; tab++; } c-=in; } if (ch=='R') { for (int i=1;i<=in;i++) { if (c+i<=m && (table[l][c+i]==-1 || tab<table[l][c+i]) && l>=1 && l<=n && c+i>=1) table[l][c+i]=tab; tab++; } c+=in; } } int main() { for (int i=0;i<maxn;i++) { for (int i2=0;i2<maxn;i2++) table[i][i2]=-1; } cin>>n>>m>>k; for (int i=0;i<k;i++) { cin>>x>>y>>t; l=x; c=y; if (t==0) { rec[0]='U'; rec[1]='R'; rec[2]='D'; rec[3]='L'; } if (t==1) { rec[0]='U'; rec[1]='L'; rec[2]='D'; rec[3]='R'; } d=0; tab=2; table[x][y]=1; for (int i=0;i<100;i++) { for (int i2=0;i2<4;i2++) { if (i2==0 || i2==2) d++; doing(rec[i2],d); } } } for (int i=1;i<=n;i++) { for (int i2=1;i2<=m;i2++) cout<<table[i][i2]<<" "; cout<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...