QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#106615 | #6314. 过河卒 | sichengzhou | 45 | 1474ms | 35060kb | C++14 | 4.3kb | 2023-05-18 12:00:17 | 2023-05-18 12:01:31 |
Judging History
answer
#include<bits/stdc++.h>
#define pdx pd[x1][Y1][x2][y2][x3][y3][i]
#define dpx dp[x1][Y1][x2][y2][x3][y3][i]
#define dx d[x1][Y1][x2][y2][x3][y3][i]
#define idx (int)(1e6*x1+1e5*Y1+1e4*x2+1e3*y2+1e2*x3+1e1*y3+i)
using namespace std;
const int N=10,M=2e6+10;
int n,m,pd1,f1,id1;
char ch[N][N];
int dp[N][N][N][N][N][N][2],pd[N][N][N][N][N][N][2],d[N][N][N][N][N][N][2];
int q[M],hh,tt;
int i,x1,Y1,x2,y2,x3,y3;
void work()
{
if(pdx)
{
return ;
}
if(idx==1012210)
{
// cout<<f1<<' '<<pd1<<' '<<id1<<endl;
}
if(pd1==1)
{
pdx=2;
dpx=f1+1;
dx=0;
q[++tt]=idx;
}else{
dpx=f1+1;
dx--;
if(dx==0)
{
q[++tt]=idx;
pdx=1;
}
}
}
void work1()
{
memset(pd,0,sizeof(pd));
hh=1,tt=0;
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
{
scanf("%s",ch[i]);
}
// cout<<"**\n";
for(int x1=0;x1<n;x1++)
{
for(int Y1=0;Y1<n;Y1++)
{
for(int x2=0;x2<n;x2++)
{
for(int y2=0;y2<n;y2++)
{
for(int x3=0;x3<n;x3++)
{
for(int y3=0;y3<n;y3++)
{
for(int i=0;i<2;i++)
{
if((ch[x1][Y1]=='#'||ch[x2][y2]=='#')&&i==1||
ch[x3][y3]=='#'&&i==0
||x1==x2&&Y1==y2&&i==1)
{
dp[x1][Y1][x2][y2][x3][y3][i]=-1;
pd[x1][Y1][x2][y2][x3][y3][i]=2;
continue;
}
if(x3==0&&i==0)
{
dp[x1][Y1][x2][y2][x3][y3][i]=0;
pd[x1][Y1][x2][y2][x3][y3][i]=1;
continue;
}
if(x1==x3&&Y1==y3||x2==x3&&y2==y3)
{
dp[x1][Y1][x2][y2][x3][y3][i]=0;
// if(x2*y2*x3*y3==1)cout<<x1<<' '<<Y1<<' '<<i<<endl;
pd[x1][Y1][x2][y2][x3][y3][i]=1;
continue;
}
}
}
}
}
}
}
}
// cout<<"**\n";
for(int x1=0;x1<n;x1++)
{
for(int Y1=0;Y1<n;Y1++)
{
for(int x2=0;x2<n;x2++)
{
for(int y2=0;y2<n;y2++)
{
for(int x3=0;x3<n;x3++)
{
for(int y3=0;y3<n;y3++)
{
for(int i=0;i<2;i++)
{
if(pd[x1][Y1][x2][y2][x3][y3][i])
{
q[++tt]=x1*1e6+Y1*1e5+x2*1e4+y2*1e3+x3*1e2+y3*1e1+i;
continue;
}
// cout<<tt<<endl;
if(i==0)
{
d[x1][Y1][x2][y2][x3][y3][i]=(x1>0)+(x1<n-1)
+(Y1>0)+(Y1<n-1)+(x2>0)+(x2<n-1)+(y2>0)+(y2<n-1);
}else{
d[x1][Y1][x2][y2][x3][y3][i]=(x3>0)+(y3>0)+(y3<n-1);
}
}
}
}
}
}
}
}
// cout<<tt<<endl;
// cout<<"**\n";
while(hh<=tt)
{
// cout<<q[hh]<<endl;getchar();
i=q[hh]%10,y3=q[hh]/10%10,x3=q[hh]/100%10,y2=q[hh]/1000%10,
x2=q[hh]/10000%10,Y1=q[hh]/100000%10,x1=q[hh]/1000000%10;hh++;
pd1=pd[x1][Y1][x2][y2][x3][y3][i];
f1=dp[x1][Y1][x2][y2][x3][y3][i];
id1=idx;
if(i==0)
{
i^=1;
if(x3<n-1)
{
x3++;work();x3--;
}
if(y3>0)
{
y3--;work();y3++;
}
if(y3<n-1)
{
y3++;work();y3--;
}
i^=1;
}else{
i^=1;
if(x2>0)
{
x2--;work();x2++;
}
if(x2<n-1)
{
x2++;work();x2--;
}
if(y2>0)
{
y2--;work();y2++;
}
if(y2<n-1)
{
y2++;work();y2--;
}
if(x1>0)
{
x1--;work();x1++;
}
if(x1<n-1)
{
x1++;work();x1--;
}
if(Y1>0)
{
Y1--;work();Y1++;
}
if(Y1<n-1)
{
Y1++;work();Y1--;
}
i^=1;
}
}
i=0;x1=-1;Y1=-1;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(ch[i][j]=='O')
{
if(x1==-1)
{
x1=i,Y1=j;
}else{
x2=i,y2=j;
}
}else if(ch[i][j]=='X')
{
x3=i,y3=j;
}
}
}
// cout<<tt<<endl;
if(pdx==0)
{
printf("Tie\n");
}else if(pdx==1)
{
printf("Black %d\n",dpx);
}else{
printf("Red %d\n",dpx);
}
// cout<<dx<<endl;
// cout<<dp[4][2][3][8][7][2][1]<<' '<<pd[4][2][3][8][7][2][1]<<endl;
/* cout<<d[1][1][1][2][2][1][1]<<' '<<pd[1][1][1][2][2][1][1]<<endl;
cout<<d[1][0][1][1][2][1][1]<<' '<<pd[1][0][1][1][2][1][1]<<endl;
cout<<dp[1][1][1][2][1][1][0]<<' '<<pd[1][1][1][2][1][1][0]<<endl;
cout<<dp[1][0][1][1][1][1][0]<<' '<<pd[1][0][1][1][1][1][0]<<endl;*/
}
/*
3 3
#.#
O.O
.X.
*/
int main()
{
int T;
scanf("%d",&T);
scanf("%d",&T);
while(T--)
{
work1();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1290ms
memory: 35060kb
input:
1 10 10 10 .#......#. ..#....#.. #..#..#..# ..#.O..#.. .#......#. ...####... ##..X...## .......... .##.O####. .......... 10 10 .##..##... .....##... ..X#.#.... #........# ..#.#.#... .#...#.#.. #..#.#.#.. ..#..#.#.# ...##O#... ..##O#.#.. 4 1 O O # X 10 10 .##.....## ...#....## .#.#...#.. .O###..... #...
output:
Tie Black 0 Red 9 Tie Black 0 Tie Black 0 Black 0 Tie Tie
result:
wrong answer 3rd lines differ - expected: 'Black 0', found: 'Red 9'
Test #2:
score: 0
Wrong Answer
time: 1200ms
memory: 34760kb
input:
2 10 10 10 .#.####..# .##..##### ##.###X### #....####. .#.####### #.#O###.## ..##.####. ..######## ########## ##O#.#.### 10 10 ..#.###.## ......#..# ....#O.... #..#.....# ...#.##### .....#..#. ..#.....#O X#....###. #.....##.. .#..##.... 10 10 .......##. .O##...##. ..#....... ####..O... ....#...## .....
output:
Black 0 Tie Tie Black 0 Black 0 Tie Red 9 Tie Tie Black 0
result:
wrong answer 7th lines differ - expected: 'Black 0', found: 'Red 9'
Test #3:
score: 5
Accepted
time: 1298ms
memory: 34800kb
input:
3 10 10 10 ##.####### ###..###OO ##X####.## ...####### #..###...# ##...##### ##..#.#### ..##..##.# ###..#.#.# #.###..##. 10 10 .##..##... .....##... ..X#.#.... #........# ..#.#.#... .#...#.#.. #..#.#.#.. ..#..#.#.# ...##O#... ..##O#.#.. 10 10 .......... .X........ .......... .......... ..#....... .....
output:
Black 0 Black 0 Black 0 Black 0 Black 0 Tie Tie Tie Tie Tie
result:
ok 10 lines
Test #4:
score: 0
Wrong Answer
time: 1091ms
memory: 34768kb
input:
4 10 10 10 .#......#. ..#....#.. #..#..#..# ..#.O..#.. .#......#. ...####... ##..X...## .......... .##.O####. .......... 10 10 ...#.##... ..####.##. ###.###### .####O#.X# ...####..# .##O#..#.# ##.#..###. #.#.#....# .#.#####.# .##.#.#.## 3 2 OO ## #X 10 10 .##.##...# ..##..#.#O .#O#.#...# #.#.#..##. ...
output:
Tie Black 0 Red 7 Black 0 Black 0 Black 0 Tie Tie Tie Tie
result:
wrong answer 3rd lines differ - expected: 'Black 0', found: 'Red 7'
Test #5:
score: 0
Wrong Answer
time: 1419ms
memory: 35040kb
input:
5 10 10 10 .......... ....O..... .......... ...X...... .......... .......... .......... .......... ########## .......O.. 10 10 .......... ..O....... .......... .......... .......... X......... .......... .......... ########## .......O.. 10 1 . . . O . . . X # O 10 1 O . . . . . . X # O 10 10 ..........
output:
Red 9 Red 21 Red 25 Red 29 Black 8 Red 23 Black 14 Red 25 Red 23 Red 1
result:
wrong answer 3rd lines differ - expected: 'Black 12', found: 'Red 25'
Test #6:
score: 0
Wrong Answer
time: 1165ms
memory: 34992kb
input:
6 10 10 10 .....O.... .......... .......... .......... .......... .X........ .......... .......... ########## ...O...... 10 1 O . . . . . . X # O 10 10 .......... ..O....... .......... .......... .......... X......... .......... .......... ########## .......O.. 10 10 .......... .....O.... .............
output:
Red 17 Red 29 Red 21 Red 17 Red 11 Black 12 Black 6 Red 25 Red 23 Black 10
result:
wrong answer 2nd lines differ - expected: 'Red 7', found: 'Red 29'
Test #7:
score: 0
Wrong Answer
time: 1305ms
memory: 34820kb
input:
7 10 10 1 . O # . . X . # . O 10 1 O . . . . . . X . O 10 1 . . # O O # # . . X 5 1 O O . X . 10 1 O # . . . . . X . O 9 1 O # O . . . . . X 10 1 . . . . X O . # . O 10 1 O O . # . . . . . X 10 1 . . . . . . X . O O 10 1 O . . . # X # O . .
output:
Red 25 Red 29 Red 25 Red 11 Red 29 Red 27 Red 1 Red 33 Black 12 Red 25
result:
wrong answer 1st lines differ - expected: 'Red 5', found: 'Red 25'
Test #8:
score: 0
Wrong Answer
time: 1282ms
memory: 34848kb
input:
8 10 10 1 . . # . X # . O # O 10 1 . O O . X . . . . . 10 1 O O . . . . . . . X 5 1 . # O X O 10 1 O # . . . . X . . O 9 1 O # O . . . . X . 10 1 # . . . X O . # . O 10 1 O O # # . . . . . X 10 1 # . . . . . X . O O 10 1 . # O . # O . X # .
output:
Black 10 Red 21 Red 33 Red 1 Red 29 Red 23 Red 1 Red 33 Black 14 Red 21
result:
wrong answer 1st lines differ - expected: 'Red 3', found: 'Black 10'
Test #9:
score: 0
Wrong Answer
time: 1320ms
memory: 34848kb
input:
9 10 10 1 # O # . . X . # . O 10 1 O . . . X . . . . O 10 1 . . # O O . # . . X 5 1 O O . X . 10 1 O # . # . . . X . O 9 1 O . # O . . . X . 10 1 . . . . X O . . . O 10 1 O O . # # . . . . X 10 1 . . . . X . # . O O 10 1 . # O # O . . X # .
output:
Red 25 Red 25 Red 25 Red 11 Red 29 Red 23 Red 1 Red 33 Black 8 Red 21
result:
wrong answer 1st lines differ - expected: 'Red 5', found: 'Red 25'
Test #10:
score: 5
Accepted
time: 1438ms
memory: 34840kb
input:
10 10 10 10 .###..###. .....O...# .##.#..... ..##.##.X# ##......#. #...#..... ....##...# ..#..O##.# #..#.##... .....##.#. 10 10 #...##..#. #......##. ..##....#. #.#.##..#O .O...#.##. .....##.X. .###...... ....#.#.#. .......##. ###...##.# 10 10 #.#....... ..##..##.. ..##.#X..O ....#..... #..#....#. #...
output:
Red 7 Red 5 Red 3 Black 2 Red 9 Tie Tie Red 9 Red 9 Red 7
result:
ok 10 lines
Test #11:
score: 5
Accepted
time: 1405ms
memory: 35032kb
input:
11 10 10 10 ...#.....# ..#....... ##.##.###. ##...#.##X .....#...# ...#.#.O.# ..#...#... .....#.... ......#..# #...#...O# 10 10 ..###O#O#. .#.###.##. ##..#..#.. ....#X.... ........## ........## #...##.... ...#..###. ........#. ..#...#.#. 10 10 ######...# O.X.O####. #.#.#.#... #.......#. ...##...#. ....
output:
Black 8 Black 0 Black 2 Tie Tie Red 9 Tie Red 9 Red 9 Red 1
result:
ok 10 lines
Test #12:
score: 0
Wrong Answer
time: 1084ms
memory: 34888kb
input:
12 10 10 10 ##..##..O. .#........ .#.......# .......... #......... .XO##..... #......... .......... .......... .......... 5 6 #.#### #.#### #.OO## #X#### ###### 10 10 ....###### .######### O...##.### .######### ....###### ####....#. ####.####. ####.O..#. #######.#. ####....#X 10 10 .......... .........
output:
Red 1 Black 2 Red 9 Tie Red 9 Black 6 Tie Tie Red 5 Tie
result:
wrong answer 9th lines differ - expected: 'Red 3', found: 'Red 5'
Test #13:
score: 0
Wrong Answer
time: 1230ms
memory: 34820kb
input:
13 10 10 10 .##...#... .#####..## #..#..#..# #........# #...#.#.#. ....#..... ..#####... ....#..#.. ..##O#.... .X...O##.# 10 10 .##......# ..#..##..O ...#.##... ##..#O..## ..#...#... ###.....#X ..#....... .##.#.#... .#.#.#..#. #......#.# 10 10 .........# .......... O......... .......... ....O..... ....
output:
Black 6 Red 9 Red 9 Red 9 Red 11 Tie Red 7 Red 7 Tie Tie
result:
wrong answer 5th lines differ - expected: 'Black 8', found: 'Red 11'
Test #14:
score: 5
Accepted
time: 1470ms
memory: 34784kb
input:
14 10 10 10 .......O.. .......... .......... O......... .......... .......... .......... .......... .......X.. .......... 10 10 .##...#... .#####..## ...#..##.# #........# #...#.#.#. ....#..... ..#####... ....#..#.. ..##O#.... .X...O##.# 10 10 .#..O...#. ...####... ##.X....## .......... .#.O..#... ....
output:
Red 27 Black 6 Tie Black 8 Red 17 Red 63 Black 12 Red 17 Black 16 Red 5
result:
ok 10 lines
Test #15:
score: 0
Wrong Answer
time: 1354ms
memory: 34848kb
input:
15 10 10 10 .########O .........# ########.# .........# .######### .......... #########. .......... .######### .......O.X 10 10 .##...#... .#####..## ...#..##.# #........# #...#.#.#. ....#..... ..#####... ....#..#.. ..##O#.... .X...O##.# 10 8 ####.... ...#..#. .###..#. ...#.O#. ##.#..#. ...####. .##...
output:
Black 102 Black 6 Red 25 Red 9 Tie Red 63 Red 93 Red 139 Red 45 Black 44
result:
wrong answer 3rd lines differ - expected: 'Red 13', found: 'Red 25'
Test #16:
score: 5
Accepted
time: 1437ms
memory: 35044kb
input:
16 10 10 10 ....###### .######### O...##.### .######### ....###### ####....#. ####.####. ####.O..#. #######.#. ####....#X 10 10 .#..O...#. ...####... ##.X....## .......... .#.O..#... .#....#... .#....#... ..####.... .......... .......... 10 10 O######### #..#..#... ..#..#..## .#..#..#.. ...#..#..# ....
output:
Red 9 Tie Black 50 Red 333 Red 41 Black 6 Red 133 Black 24 Red 111 Red 101
result:
ok 10 lines
Test #17:
score: 5
Accepted
time: 1474ms
memory: 34824kb
input:
17 10 10 10 ########## .......... .......... ..######## .......... #########. .O........ .......... #......... O#X....... 10 10 .##...#... .#####..## ...#..##.# #........# #...#.#.#. ....#..... ..#####... ....#..#.. ..##O#.... .X...O##.# 10 10 #.......O. ..#....... ...##.##.. .......... .......... ....
output:
Black 60 Black 6 Red 53 Red 35 Tie Tie Red 9 Red 65 Tie Red 63
result:
ok 10 lines
Test #18:
score: 5
Accepted
time: 1293ms
memory: 34824kb
input:
18 10 10 10 O......... #..#..###. .#.##...#. ..X....... .####..... .##...##.# ...#..###. ...###..O# ..#..#.... .......### 10 10 ...#.....O ........#. ........X. .......... ...#...... .......... .........# .....O.... ..#....... .......... 10 10 ..O.#..... #.#...#... ...#..###. ....#..... ..#..#..#. #...
output:
Red 159 Tie Red 73 Black 36 Black 56 Black 6 Red 15 Black 0 Red 63 Black 2
result:
ok 10 lines
Test #19:
score: 5
Accepted
time: 1369ms
memory: 34764kb
input:
19 10 10 10 .....#.... ...#.#.#.# #..#.##.#. .##.....#. .#..##.#.# ...#...... #.#.#.##.. ##...#O##. ..#.#O.... .#...#..X. 10 10 .O....#... .####....# .###...#.. .......... ###....##. ....#..##. .#.#.#.... .##.O#..#. #..#...#.. ...#....X# 10 10 O######### #..#..#... ..#..#..## .#..#..#.. ...#..#..# ....
output:
Black 6 Red 57 Black 50 Red 11 Tie Red 129 Red 99 Black 0 Red 111 Red 27
result:
ok 10 lines
Test #20:
score: 5
Accepted
time: 1427ms
memory: 34908kb
input:
20 10 10 10 .##.....## ...#....## .#.#...#.. .O###..... ###....... ......###. .....#..O. ##........ ..#...X... .##....... 10 10 #...#.##.. .O##.....# #.#.....#. .#...#.... ....#..#.. .###...... ....O##.#. .#.#.....# .......... .#.#...X#. 10 10 ......###. ..#.#..##. .#.......# .#.#..###. ..#.#..#.. #...
output:
Tie Red 63 Red 61 Red 9 Black 6 Black 0 Tie Red 333 Red 57 Tie
result:
ok 10 lines