Submission #83287

# Submission time Handle Problem Language Result Execution time Memory
83287 2018-11-06T16:30:17 Z charlies_moo Spirale (COCI18_spirale) C++
80 / 80
84 ms 25332 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
	//freopen("spiral.in","r",stdin);
	//freopen("spiral.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int s1[101][101],s2[101][101];
	int l=1;
	int x=50;
	int y=50;
	s1[50][50]=1;
	for(int i=1;i<=99;i+=2)
	{
		for(int j=1;j<=i;j++)
		{
			l++;
			x--;
			s1[x][y]=l;
		}
		for(int j=1;j<=i;j++)
		{
			l++;
			y--;
			s1[x][y]=l;
		}
		for(int j=1;j<=i+1;j++)
		{
			l++;
			x++;
			s1[x][y]=l;
		}
		for(int j=1;j<=i+1;j++)
		{
			l++;
			y++;
			s1[x][y]=l;
		}
	}
	for(int j=1;j<=101;j++)
		{
			l++;
			x--;
			s1[x][y]=l;
		}
	for(int j=1;j<=101;j++)
		{
			l++;
			y--;
			s1[x][y]=l;
		}
	for(int i=0;i<101;i++)
	{
		for(int j=0;j<101;j++)
			s2[i][j]=s1[i][100-j];
	}
	int m,n,k;
	cin>>m>>n>>k;
	int s[m][n][k];
	memset(s,0,sizeof(s));
	for(int i=0;i<k;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		if(c==1)
		{
			for(int p=0;p<m;p++)
			{
				for(int q=0;q<n;q++)
					s[p][q][i]=s1[51-a+p][51-b+q];
			}
		}
		else
		{
			for(int p=0;p<m;p++)
			{
				for(int q=0;q<n;q++)
					s[p][q][i]=s2[51-a+p][51-b+q];
			}
		}
	}
	for(int p=0;p<m;p++)
	{
		for(int q=0;q<n;q++)
		{
			int mi=s[p][q][0];
			for(int r=1;r<k;r++)
			{
				if(mi>s[p][q][r])
					mi=s[p][q][r];
			}
			cout<<mi<<" ";
		}
		cout<<endl;
	}
	
//	fclose(stdin);
//	fclose(stdout);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
5 Correct 2 ms 532 KB Output is correct
6 Correct 2 ms 668 KB Output is correct
7 Correct 2 ms 668 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 84 ms 25332 KB Output is correct
10 Correct 3 ms 25332 KB Output is correct