QOJ.ac

QOJ

ID提交记录ID题目HackerOwner结果提交时间测评时间
#785#442397#8217. King's DinnerliyelinD_F_SFailed.2024-08-24 15:40:012024-08-24 15:40:01

详细

Extra Test:

Invalid Input

input:

1
114

output:


result:

FAIL Integer parameter [name=n] equals to 114, violates the range [1, 100] (test case 1, stdin, line 2)

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#442397#8217. King's DinnerD_F_SAC ✓1ms3876kbC++141.0kb2024-06-15 11:37:252024-06-15 11:37:25

answer

#include<bits/stdc++.h>
int T,n,a[105][105];
int main()
{
	scanf("%d",&T); for(int i=1,u,v,x,y;i<=T;++i)
	{
		scanf("%d",&n); if(n==1) {puts("."); continue; } !(u=n%6)&&(u+=6);
		for(v=u,x=1;x<=n-u;x+=3) for(y=1;y<=n-u;y+=2) a[x][y]=a[x+1][y]=i;
		if(v==3||v==6) {for(x=1;x<=n-u;x+=3) a[n-v+1][x]=a[n-v+1][x+1]=a[x][n-v+1]=a[x+1][n-v+1]=i; v-=2; }
		if(v>=3) {for(x=1;x<=n-u;x+=2) a[n-v+1][x]=a[n-v+2][x]=a[x][n-v+1]=a[x][n-v+2]=i; v-=3; }
		if(v==2) for(x=1;x<=n-u;x+=2) a[n-1][x]=a[n][x]=a[x][n-1]=a[x][n]=i;
		if(v==1) for(x=1;x<=n-u;x+=3) a[n][x]=a[n][x+1]=a[x][n]=a[x+1][n]=i;
		if(u==6) a[n-5][n-5]=a[n-5][n-4]=a[n-5][n-2]=a[n-4][n-2]=a[n-5][n]=a[n-4][n]=a[n-3][n-5]=a[n-3][n-4]=a[n-2][n-1]=a[n-2][n]=a[n-1][n-5]=a[n][n-5]=a[n-1][n-3]=a[n][n-3]=a[n][n-1]=a[n][n]=i;
		else if(u==4) a[n-3][n-3]=a[n-3][n-2]=a[n-3][n]=a[n-2][n]=a[n-1][n-3]=a[n][n-3]=a[n][n-1]=a[n][n]=i;
		else for(x=n-u+1;x<n;x+=3) for(y=n-u+1;y<=n;y+=2) a[x][y]=a[x+1][y]=i;
		for(x=1;x<=n;++x,putchar('\n')) for(y=1;y<=n;++y) putchar(a[x][y]==i?'#':'.');
	}
	return 0;
}