QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#93787#6189. Full Clue ProblemLiberty12619AC ✓2ms3568kbC++201.1kb2023-04-02 14:20:052023-04-02 14:20:09

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-02 14:20:09]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3568kb
  • [2023-04-02 14:20:05]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 30;
int a[N][N],ans1[N][N],ans2[N][N];
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
void solve()
{
	int n;
	cin>>n;
	int x=1,y=n,t=0;
	ans1[x][y]=ans2[x][y]=1;
	while(true)
	{
		if(x==n&&y==1)	break;
		if(t&1)
		{
			ans1[x+1][y]=ans1[x+1][y-1]=1;
			ans2[x][y-1]=ans2[x+1][y-1]=1;
		}
		else
		{
			ans2[x+1][y]=ans2[x+1][y-1]=1;
			ans1[x][y-1]=ans1[x+1][y-1]=1;
		}
		t++;
		x++,y--;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			int res=0;
			for(int k=0;k<4;k++)
			{
				int ix = i+dx[k],iy = j+dy[k];
				if(ix<1||ix>n||iy<1||iy>n)	continue;
				if(ans1[ix][iy])	res++;	
			}
			if(ans1[i][j])	a[i][j]=4-res;
			else	a[i][j]=res;
		}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)	cout<<a[i][j]<<" ";
		puts("");
	}
	puts("");
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)	cout<<ans1[i][j]<<" ";
		puts("");
	}
	puts("");
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)	cout<<ans2[i][j]<<" ";
		puts("");
	}
	puts("");
		
}
signed main()
{
	int T=1;
	while(T--)
	{
		solve();
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3524kb

input:

5

output:

0 0 1 2 3 
0 1 2 2 2 
1 2 2 2 1 
2 2 2 1 0 
3 2 1 0 0 

0 0 0 1 1 
0 0 0 1 0 
0 1 1 1 0 
0 1 0 0 0 
1 1 0 0 0 

0 0 0 0 1 
0 0 1 1 1 
0 0 1 0 0 
1 1 1 0 0 
1 0 0 0 0 


result:

ok ok

Test #2:

score: 0
Accepted
time: 2ms
memory: 3304kb

input:

2

output:

2 3 
3 2 

1 1 
1 0 

0 1 
1 1 


result:

ok ok

Test #3:

score: 0
Accepted
time: 2ms
memory: 3424kb

input:

3

output:

1 2 3 
2 2 2 
3 2 1 

0 1 1 
0 1 0 
1 1 0 

0 0 1 
1 1 1 
1 0 0 


result:

ok ok

Test #4:

score: 0
Accepted
time: 2ms
memory: 3520kb

input:

4

output:

0 1 2 3 
1 2 2 2 
2 2 2 1 
3 2 1 0 

0 0 1 1 
0 0 1 0 
1 1 1 0 
1 0 0 0 

0 0 0 1 
0 1 1 1 
0 1 0 0 
1 1 0 0 


result:

ok ok

Test #5:

score: 0
Accepted
time: 2ms
memory: 3564kb

input:

10

output:

0 0 0 0 0 0 0 1 2 3 
0 0 0 0 0 0 1 2 2 2 
0 0 0 0 0 1 2 2 2 1 
0 0 0 0 1 2 2 2 1 0 
0 0 0 1 2 2 2 1 0 0 
0 0 1 2 2 2 1 0 0 0 
0 1 2 2 2 1 0 0 0 0 
1 2 2 2 1 0 0 0 0 0 
2 2 2 1 0 0 0 0 0 0 
3 2 1 0 0 0 0 0 0 0 

0 0 0 0 0 0 0 0 1 1 
0 0 0 0 0 0 0 0 1 0 
0 0 0 0 0 0 1 1 1 0 
0 0 0 0 0 0 1 0 0 0 
0 0 0...

result:

ok ok

Test #6:

score: 0
Accepted
time: 0ms
memory: 3424kb

input:

19

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 
0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 
0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 
0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 
0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 0 
0 0 0 0 0 0 0 0 0 1 2 2 2 1...

result:

ok ok

Test #7:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

20

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 1 0 0 0 0 
0 0 0 0 0 0 0...

result:

ok ok