QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#818935 | #9884. Grid Construction | YMH_fourteen# | AC ✓ | 2ms | 4656kb | C++14 | 2.4kb | 2024-12-18 10:57:04 | 2024-12-18 10:57:05 |
Judging History
answer
// Author: YE Minghan
#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "templates/debug.h"
#define __int128 ll
#else
#define dbg(...) (void)0
#define msg(...) (void)0
#endif
#define ll long long
#define endl '\n'
#define PB emplace_back
#define PPB pop_back
#define MP make_pair
#define ALL(Name) Name.begin(),Name.end()
#define PII pair<int,int>
#define VI vector<int>
#define GI greater<int>
#define fi first
#define se second
const char s9[5][7]=
{
"<v>.^.",
".v.^>>",
">.<^.v",
".^.<<v",
"<^>.v."
},s11[7][7]=
{
"<v>.^.",
".v.<<^",
">.<v.^",
".^.v>>",
"<^>.v.",
"v>.^.<",
"v.<^>."
};
char a[1005][1005];
void f(int x,int y,int n,int m)
{
int lx=x-n/2,rx=x+n/2,ly=y-m/2,ry=y+m/2;
for(int i=ly;i<ry;i++)a[lx][i]='<',a[rx][i+1]='>';
for(int i=lx;i<rx;i++)a[i+1][ly]='v',a[i][ry]='^';
if(n==3)return;
for(int i=ly+2;i<ry;i+=2)a[lx+1][i]='v',a[rx-1][i]='^';
for(int i=lx+2;i<rx;i+=2)a[i][ly+1]='>',a[i][ry-1]='<';
if(n==5)return;
if(n==9)
{
a[x][ly+2]=a[x][ly+3]='>';
a[x][ry-2]=a[x][ry-3]='<';
a[x-1][ly+2]=a[x-1][ry-2]='^';
a[x+1][ly+2]=a[x+1][ry-2]='v';
for(int cy=ly+3;cy<=ry-3;cy++)
for(int cx=x-2;cx<=x+2;cx++)
a[cx][cy]=s9[cx-x+2][(cy-ly-3)%6];
return;
}
if(n==11)
{
for(int cy=ly+3;cy<=ry-3;cy++)
for(int cx=x-3;cx<=x+3;cx++)
a[cx][cy]=s11[cx-x+3][(cy-ly-3)%6];
a[x-2][ly+2]=a[x][ry-2]=a[x-2][ry-3]='^';
a[x][ly+2]=a[x+2][ry-2]='v';
a[x-1][ly+2]=a[x-2][ry-2]=a[x-1][ry-3]='>';
a[x+2][ly+2]=a[x+1][ry-2]=a[x+1][ry-3]='<';
a[x][ry-3]='.';
return;
}
for(int i=ly+3;i<ry-1;i+=2)a[lx+2][i]='^',a[rx-2][i]='v';
for(int i=lx+3;i<rx-2;i+=2)a[i][ly+2]='<',a[i][ry-2]='>';
f(x,y,n-6,m-6);
}
int main()
{
ios::sync_with_stdio(false),cin.tie(nullptr);
// int _;cin>>_;while(_--)
int n,m;
cin>>n>>m;
if(n==2&&m==2)return puts("Yes\n<^\nv>"),0;
bool SWP=0;
if(n>m)swap(n,m),SWP=1;
if(n%6!=m%6||n%6!=3&&n%6!=5||n<=5&&m>5)return puts("No"),0;
memset(a,'.',sizeof(a));
f(n/2,m/2,n,m);
puts("Yes");
if(SWP)
{
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
if(a[i][j]=='<')a[i][j]='^';
else if(a[i][j]=='^')a[i][j]='<';
else if(a[i][j]=='>')a[i][j]='v';
else if(a[i][j]=='v')a[i][j]='>';
for(int i=0;i<m;i++)
for(int j=i+1;j<m;j++)
swap(a[i][j],a[j][i]);
swap(n,m);
}
for(int i=0;i<n;i++)a[i][m]=0,puts(a[i]);
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4588kb
input:
3 3
output:
Yes <<^ v.^ v>>
result:
ok Correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
4 4
output:
No
result:
ok Correct : No
Test #3:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
4 5
output:
No
result:
ok Correct : No
Test #4:
score: 0
Accepted
time: 0ms
memory: 4656kb
input:
11 17
output:
Yes <<<<<<<<<<<<<<<<^ v.v.v.v.v.v.v.v.^ v>.<v>.^.<v>.^.<^ v.^.v.<<^.v.<^>.^ v>>>.<v.^>.<v>.<^ v.v.^.v>>.^.v.^.^ v>.<^>.v.<^>.<<<^ v.<v>.^.<v>.^.v.^ v>.v.<^>.v.<^>.<^ v.^.^.^.^.^.^.^.^ v>>>>>>>>>>>>>>>>
result:
ok Correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
1000 1000
output:
No
result:
ok Correct : No
Test #6:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
6 6
output:
No
result:
ok Correct : No
Test #7:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
7 7
output:
No
result:
ok Correct : No
Test #8:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
8 8
output:
No
result:
ok Correct : No
Test #9:
score: 0
Accepted
time: 1ms
memory: 4564kb
input:
9 9
output:
Yes <<<<<<<<^ v.v.v.v.^ v>.<v>.<^ v.^.v.^.^ v>>>.<<<^ v.v.^.v.^ v>.<^>.<^ v.^.^.^.^ v>>>>>>>>
result:
ok Correct
Test #10:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
3 9
output:
No
result:
ok Correct : No
Test #11:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
15 3
output:
No
result:
ok Correct : No
Test #12:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
5 11
output:
No
result:
ok Correct : No
Test #13:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
605 5
output:
No
result:
ok Correct : No
Test #14:
score: 0
Accepted
time: 2ms
memory: 4576kb
input:
999 999
output:
Yes <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...
result:
ok Correct
Test #15:
score: 0
Accepted
time: 1ms
memory: 4536kb
input:
9 999
output:
Yes <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...
result:
ok Correct
Test #16:
score: 0
Accepted
time: 2ms
memory: 4584kb
input:
995 995
output:
Yes <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...
result:
ok Correct
Test #17:
score: 0
Accepted
time: 1ms
memory: 4656kb
input:
995 11
output:
Yes ^>>>>>>>>>> ^.v.v.v.v.v ^>.<v>.^.<v ^.^.v.^>>.v ^>>>.<<v.<v ^.v.^.v.^.v ^>.^>>.<<<v ^.<^.v>.v.v ^>.<<v.^.<v ^.^.v.^>>.v ^>>>.<<v.<v ^.v.^.v.^.v ^>.^>>.<<<v ^.<^.v>.v.v ^>.<<v.^.<v ^.^.v.^>>.v ^>>>.<<v.<v ^.v.^.v.^.v ^>.^>>.<<<v ^.<^.v>.v.v ^>.<<v.^.<v ^.^.v.^>>.v ^>>>.<<v.<v ^.v.^.v.^.v ^>.^>>.<...
result:
ok Correct
Test #18:
score: 0
Accepted
time: 1ms
memory: 4656kb
input:
897 27
output:
Yes ^>>>>>>>>>>>>>>>>>>>>>>>>>> ^.v.v.v.v.v.v.v.v.v.v.v.v.v ^>.^.^.^.^.^.^.^.^.^.^.^.<v ^.<^>>>>>>>>>>>>>>>>>>>>>.v ^>.^.v.v.v.v.v.v.v.v.v.v.<v ^.<^>.^.^.^.^.^.^.^.^.<v>.v ^>.^.<^>>>>>>>>>>>>>>>.v.<v ^.<^>.^.v.v.v.v.v.v.v.<v>.v ^>.^.<^>.^.^.^.^.^.<v>.v.<v ^.<^>.^.<^>>>>>>>>>.v.<v>.v ^>.^.<^>.^.v.v.v...
result:
ok Correct
Test #19:
score: 0
Accepted
time: 2ms
memory: 4580kb
input:
663 597
output:
Yes ^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
result:
ok Correct
Test #20:
score: 0
Accepted
time: 1ms
memory: 4656kb
input:
879 45
output:
Yes ^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ^.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v ^>.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.<v ^.<^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.v ^>.^.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.<v ^.<^>.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.<v>.v ^>.^.<^>>>>>>>>>>>>>...
result:
ok Correct
Test #21:
score: 0
Accepted
time: 0ms
memory: 4580kb
input:
587 827
output:
Yes <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...
result:
ok Correct
Test #22:
score: 0
Accepted
time: 2ms
memory: 4584kb
input:
863 815
output:
Yes ^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
result:
ok Correct
Test #23:
score: 0
Accepted
time: 2ms
memory: 4580kb
input:
893 671
output:
Yes ^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
result:
ok Correct
Test #24:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
1000 996
output:
No
result:
ok Correct : No
Test #25:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
997 990
output:
No
result:
ok Correct : No
Test #26:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
991 996
output:
No
result:
ok Correct : No
Test #27:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
995 999
output:
No
result:
ok Correct : No
Test #28:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
658 868
output:
No
result:
ok Correct : No
Test #29:
score: 0
Accepted
time: 0ms
memory: 4588kb
input:
155 773
output:
Yes <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...
result:
ok Correct
Test #30:
score: 0
Accepted
time: 1ms
memory: 4492kb
input:
365 605
output:
Yes <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...
result:
ok Correct
Test #31:
score: 0
Accepted
time: 1ms
memory: 4540kb
input:
491 185
output:
Yes ^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ^.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v.v....
result:
ok Correct
Test #32:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
748 562
output:
No
result:
ok Correct : No
Test #33:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
54 252
output:
No
result:
ok Correct : No
Test #34:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
889 799
output:
No
result:
ok Correct : No
Test #35:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
504 600
output:
No
result:
ok Correct : No
Test #36:
score: 0
Accepted
time: 0ms
memory: 4496kb
input:
527 701
output:
Yes <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...
result:
ok Correct
Test #37:
score: 0
Accepted
time: 0ms
memory: 4584kb
input:
195 813
output:
Yes <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<...
result:
ok Correct
Test #38:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
232 402
output:
No
result:
ok Correct : No
Test #39:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
326 313
output:
No
result:
ok Correct : No
Test #40:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
594 628
output:
No
result:
ok Correct : No
Test #41:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
846 977
output:
No
result:
ok Correct : No
Test #42:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
795 894
output:
No
result:
ok Correct : No
Test #43:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
763 660
output:
No
result:
ok Correct : No
Test #44:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
707 116
output:
No
result:
ok Correct : No
Test #45:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
555 290
output:
No
result:
ok Correct : No
Test #46:
score: 0
Accepted
time: 2ms
memory: 4644kb
input:
891 597
output:
Yes ^>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>...
result:
ok Correct
Test #47:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
580 807
output:
No
result:
ok Correct : No
Test #48:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
1 1
output:
No
result:
ok Correct : No
Test #49:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
2 1
output:
No
result:
ok Correct : No
Test #50:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
1 3
output:
No
result:
ok Correct : No
Test #51:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1 4
output:
No
result:
ok Correct : No
Test #52:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
5 1
output:
No
result:
ok Correct : No
Test #53:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
2 2
output:
Yes <^ v>
result:
ok Correct
Test #54:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
2 3
output:
No
result:
ok Correct : No
Test #55:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
2 4
output:
No
result:
ok Correct : No
Test #56:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
2 5
output:
No
result:
ok Correct : No
Test #57:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
3 4
output:
No
result:
ok Correct : No
Test #58:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
5 3
output:
No
result:
ok Correct : No
Test #59:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
5 4
output:
No
result:
ok Correct : No
Test #60:
score: 0
Accepted
time: 1ms
memory: 4544kb
input:
5 5
output:
Yes <<<<^ v.v.^ v>.<^ v.^.^ v>>>>
result:
ok Correct
Extra Test:
score: 0
Extra Test Passed