QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#443283 | #8217. King's Dinner | jinqihao2023 | AC ✓ | 4ms | 3884kb | C++14 | 2.0kb | 2024-06-15 15:01:53 | 2024-06-15 15:01:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int T,n,ans[N][N];
void slv(int len,int st)
{
if(len==1)return ;
if(len==2){ans[st][st]=ans[st][st+1]=1;return ;}
if(len==3){ans[st][st]=ans[st][st+1]=ans[st+2][st]=ans[st+2][st+1]=1;return ;}
if(len==4){ans[st][st]=ans[st][st+1]=ans[st][st+3]=ans[st+1][st+3]=ans[st+3][st+3]=ans[st+3][st+2]=ans[st+3][st]=ans[st+2][st]=1;return ;}
if(len==6)
{
ans[st][st]=ans[st][st+1]=ans[st][st+3]=ans[st][st+5]=1;
ans[st+1][st+3]=ans[st+1][st+5]=1;
ans[st+2][st]=ans[st+2][st+1]=1;
ans[st+3][st+4]=ans[st+3][st+5]=1;
ans[st+4][st]=ans[st+4][st+2]=1;
ans[st+5][st]=ans[st+5][st+2]=ans[st+5][st+4]=ans[st+5][st+5]=1;
return ;
}
if(len%3==0)
{
for(int i=0;i<=len-6;i+=3)
{
ans[st][st+i]=ans[st][st+i+1]=ans[st+2][st+i]=ans[st+2][st+i+1]=1;
ans[st+i][st+len-3]=ans[st+i][st+len-1]=ans[st+i+1][st+len-3]=ans[st+i+1][st+len-1]=1;
ans[st+len-3][st+len-1-i]=ans[st+len-3][st+len-1-i-1]=ans[st+len-1][st+len-1-i]=ans[st+len-1][st+len-1-i-1]=1;
ans[st+len-1-i][st]=ans[st+len-1-i-1][st]=ans[st+len-1-i][st+2]=ans[st+len-1-i-1][st+2]=1;
}
slv(len-8,st+4);
return ;
}
if(len%3==1)
{
for(int i=0;i<=len-4;i+=3)
{
ans[st][st+i]=ans[st][st+i+1]=1;
ans[st+i][st+len-1]=ans[st+i+1][st+len-1]=1;
ans[st+len-1][st+len-1-i]=ans[st+len-1][st+len-1-i-1]=1;
ans[st+len-1-i][st]=ans[st+len-1-i-1][st]=1;
}
slv(len-4,st+2);
return ;
}
if(len%2==1)
{
for(int i=st;i<=st+len-1;i+=2)
{
for(int j=st;j<=st+len-2;j+=3)
{
ans[i][j]=ans[i][j+1]=1;
}
}
return ;
}
for(int i=st;i<=st+len-2;i+=2)ans[st][i]=ans[st+1][i]=1;
for(int i=st+3;i<=st+len-1;i+=2)
{
for(int j=st;j<=st+len-2;j+=3)ans[i][j]=ans[i][j+1]=1;
}
return ;
}
void solve()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)ans[i][j]=0;
slv(n,1);
for(int i=1;i<=n;i++,printf("\n"))for(int j=1;j<=n;j++)if(ans[i][j])printf("#");else printf(".");
}
int main()
{
scanf("%d",&T);
while(T--)solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3828kb
input:
3 1 2 3
output:
. ## .. ##. ... ##.
result:
ok all tests correct (3 test cases)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
50 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
output:
. ## .. ##. ... ##. ##.# ...# #... #.## ##.## ..... ##.## ..... ##.## ##.#.# ...#.# ##.... ....## #.#... #.#.## ##.##.# ......# #.##... #.....# ..##..# #...... #.##.## #.#.#.#. #.#.#.#. ........ ##.##.## ........ ##.##.## ........ ##.##.## ##.##.#.# ......#.# ##.##.... ......#.# #.#...#.# #.#...... ...
result:
ok all tests correct (50 test cases)
Test #3:
score: 0
Accepted
time: 4ms
memory: 3884kb
input:
39 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
output:
##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#.# ................................................#.# ##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.... ................................................#.# #.#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#.#.# #.#........................................
result:
ok all tests correct (39 test cases)
Test #4:
score: 0
Accepted
time: 2ms
memory: 3868kb
input:
11 90 91 92 93 94 95 96 97 98 99 100
output:
##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#.# .......................................................................................#.# ##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.... ..............................
result:
ok all tests correct (11 test cases)
Test #5:
score: 0
Accepted
time: 1ms
memory: 3808kb
input:
1 100
output:
##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.# ...................................................................................................# #.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#.#...
result:
ok all tests correct (1 test case)
Extra Test:
score: 0
Extra Test Passed