QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#320163 | #8217. King's Dinner | ucup-team987# | AC ✓ | 1ms | 3884kb | C++20 | 2.8kb | 2024-02-03 14:15:56 | 2024-02-03 14:15:56 |
Judging History
answer
#include<iostream>
#include<vector>
#include<cassert>
using namespace std;
int sz;
vector<vector<int> >A;
vector<string>ans;
void putA(int x,int y)
{
++sz;
for(int i=0;i<2;i++)for(int j=0;j<3;j++)
{
assert(A.at(x+i).at(y+j)==-1);
A.at(x+i).at(y+j)=sz;
if(i==0&&j<2)
{
assert(ans.at(x+i).at(y+j)=='.');
ans.at(x+i).at(y+j)='#';
}
}
}
void putB(int x,int y)
{
++sz;
for(int i=0;i<3;i++)for(int j=0;j<2;j++)
{
assert(A.at(x+i).at(y+j)==-1);
A.at(x+i).at(y+j)=sz;
if(i<2&&j==0)
{
assert(ans.at(x+i).at(y+j)=='.');
ans.at(x+i).at(y+j)='#';
}
}
}
void dfs(int N,int x,int y)
{
if(N==1)
{
return;
}
else if(N==2)
{
return;
}
else if(N==3)
{
putA(x,y);
return;
}
else if(N==4)
{
putA(x,y);
putA(x+2,y);
return;
}
else if(N==5)
{
putA(x,y);
putB(x,y+3);
putA(x+3,y+2);
putB(x+2,y);
return;
}
else if(N==7)
{
putB(x,y);
putB(x,y+2);
putA(x,y+4);
putA(x+2,y+4);
putB(x+4,y+3);
putB(x+4,y+5);
putA(x+3,y);
putA(x+5,y);
return;
}
auto f=[](int x,int y)
{
putA(x,y);
putA(x+2,y);
putA(x+4,y);
putA(x,y+3);
putA(x+2,y+3);
putA(x+4,y+3);
};
if(N%6==0)
{
for(int tx=0;tx<N;tx+=6)for(int ty=0;ty<N;ty+=6)
{
f(x+tx,y+ty);
}
return;
}
auto f2h=[](int x,int y)
{
putB(x,y);
putB(x+3,y);
};
auto f2w=[](int x,int y)
{
putA(x,y);
putA(x,y+3);
};
auto f3h=[](int x,int y)
{
putA(x,y);
putA(x+2,y);
putA(x+4,y);
};
auto f3w=[](int x,int y)
{
putB(x,y);
putB(x,y+2);
putB(x,y+4);
};
if(N%6==1)
{
assert(N>=13);
dfs(7,x,y);
dfs(N-7,x+7,y+7);
for(int t=7;t<N;t+=6)
{
f2h(x+t,y);
f2h(x+t,y+2);
f3h(x+t,y+4);
f2w(x,y+t);
f2w(x+2,y+t);
f3w(x+4,y+t);
}
}
else if(N%6==2)
{
dfs(N-2,x+2,y+2);
for(int t=2;t<N;t+=6)
{
f2h(x+t,y);
f2w(x,y+t);
}
}
else if(N%6==3)
{
dfs(3,x,y);
dfs(N-3,x+3,y+3);
for(int t=3;t<N;t+=6)
{
f3h(x+t,y);
f3w(x,y+t);
}
}
else if(N%6==4)
{
dfs(4,x,y);
dfs(N-4,x+4,y+4);
for(int t=4;t<N;t+=6)
{
f2h(x+t,y);
f2h(x+t,y+2);
f2w(x,y+t);
f2w(x+2,y+t);
}
}
else if(N%6==5)
{
dfs(5,x,y);
dfs(N-5,x+5,y+5);
for(int t=5;t<N;t+=6)
{
f2h(x+t,y);
f3h(x+t,y+2);
f2w(x,y+t);
f3w(x+2,y+t);
}
}
else assert(false);
}
void solve(int N)
{
A=vector<vector<int> >(N+1,vector<int>(N+1,-1));
ans=vector<string>(N,string(N,'.'));
sz=0;
dfs(N+1,0,0);
assert((N+1)*(N+1)/6==sz);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
/*
for(int N=1;N<=20;N++)
{
solve(N);
for(int i=0;i<N;i++)cout<<ans[i]<<"\n";
}
*/
int T;cin>>T;
for(;T--;)
{
int N;cin>>N;
solve(N);
for(int i=0;i<N;i++)cout<<ans[i]<<"\n";
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
3 1 2 3
output:
. ## .. ##. ... ##.
result:
ok all tests correct (3 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3884kb
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: 1ms
memory: 3600kb
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: 1ms
memory: 3696kb
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: 0ms
memory: 3604kb
input:
1 100
output:
##.#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.## ...#................................................................................................ #....#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...
result:
ok all tests correct (1 test case)
Extra Test:
score: 0
Extra Test Passed