ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#211406 | #3803. 激光 | mygr | 33 | 2753ms | 10004kb | C++ | 1.7kb | 2024-08-11 11:07:52 | 2024-08-11 13:04:43 |
answer
#include<bits/stdc++.h>
using namespace std;
const int Max=1005;
int tx[8]={0,-1,1,0,0},ty[8]={0,0,0,-1,1};
int Map[Max][Max][5],to[Max][Max][2];
bool vis[Max][Max];
char c[Max][Max];
int n,m;
char getc()
{
char c=getchar();
while(c!='.' and c!='#' and c!='/' and c!='\\' and c!='X')
c=getchar();
return c;
}
int dfs(int x,int y,int tow)
{
int ans=0;
if(Map[x][y][tow])
return ans;
if(!vis[x][y])
ans++;
vis[x][y]=1;
Map[x][y][tow]=1;
if(c[x][y]=='\\')
tow=(tow+1)%4+1;
else if(c[x][y]=='/')
{
if(tow==1)tow=4;
else if(tow==4)tow=1;
else if(tow==2)tow=3;
else if(tow==3)tow=2;
}
int nx=x+tx[tow],ny=y+ty[tow];
if(nx<1 or nx>n or ny<1 or ny>m or c[nx][ny]=='#')
return ans;
if(c[nx][ny]=='X')
{
if(!vis[nx][ny])
{
vis[nx][ny]=1;
ans++;
}
x=nx;y=ny;
nx=to[x][y][0];
ny=to[x][y][1];
}
ans+=dfs(nx,ny,tow);
return ans;
}
void clear()
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
vis[i][j]=0;
for(int k=1;k<=4;k++)
Map[i][j][k]=0;
}
}
}
void solve1()
{
for(int k=1;k<=4;k++)
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(c[i][j]=='.')
{
clear();
printf("%d ",dfs(i,j,k));
}
else
printf("-1 ");
}
printf("\n");
}
}
}
int main()
{
scanf("%d%d",&n,&m);
int k=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
c[i][j]=getc();
if(c[i][j]=='X')
k++;
}
}
int X1,X2,Y1,Y2;
for(int i=1;i<=k/2;i++)
{
scanf("%d%d%d%d",&X1,&Y1,&X2,&Y2);
to[X1][Y1][0]=X2;
to[X1][Y1][1]=Y2;
to[X2][Y2][0]=X1;
to[X2][Y2][1]=Y1;
}
if(n<=60 and m<=60)
solve1();
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 3
Accepted
time: 94ms
memory: 1544kb
input:
50 50 .......................#.........#................ ..............................................
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 10000 tokens
Test #2:
score: 0
Wrong Answer
time: 3ms
memory: 1652kb
input:
500 500 ...............................................................................................
output:
result:
wrong answer Unexpected EOF in the participants output
Test #3:
score: 0
Wrong Answer
time: 13ms
memory: 2148kb
input:
1000 1000 #.....#..#...............#..#.##......#......#...........#....#....#.#.......#..........##...
output:
result:
wrong answer Unexpected EOF in the participants output
Test #4:
score: 0
Wrong Answer
time: 2ms
memory: 2136kb
input:
990 831 ...............................................................................................
output:
result:
wrong answer Unexpected EOF in the participants output
Test #5:
score: 0
Wrong Answer
time: 3ms
memory: 2144kb
input:
1000 1000 .............................................................................................
output:
result:
wrong answer Unexpected EOF in the participants output
Test #6:
score: 3
Accepted
time: 0ms
memory: 1224kb
input:
3 3 /X\ X.X .X/ 1 2 2 3 2 1 3 2
output:
-1 -1 -1 -1 7 -1 7 -1 -1 -1 -1 -1 -1 4 -1 1 -1 -1 -1 -1 -1 -1 4 -1 1 -1 -1 -1 -1 -1 -1 7 -...
result:
ok 36 tokens
Test #7:
score: 3
Accepted
time: 0ms
memory: 1260kb
input:
7 7 /X.X.X\ X\.\./X ....... X\././X ....... X\./.\X \X.X.X/ 1 2 7 2 1 4 7 4 1 6 7 6 2 1 2 7 4 1 4 7 ...
output:
-1 -1 1 -1 1 -1 -1 -1 -1 2 -1 2 -1 -1 18 27 3 27 3 27 18 -1 -1 4 -1 4 -1 -1 18 27 5 27 5 27 18 ...
result:
ok 196 tokens
Test #8:
score: 3
Accepted
time: 0ms
memory: 1272kb
input:
9 10 #./....\.. ..../.X..# /.X..../.. ./.\./.... ..X../..#. \/.\...\.. ..X...\/.. .X....X..\ ....X.....
output:
-1 1 -1 1 1 1 1 -1 1 1 1 2 17 2 -1 2 -1 12 2 -1 -1 3 -1 3 11 3 28 -1 3 1 28 -1 22 -1 12 -1 28 4 4...
result:
ok 360 tokens
Test #9:
score: 3
Accepted
time: 37ms
memory: 1672kb
input:
50 50 .././.\.\\.\\.\/\\.//..\\..//\./////..\//..//\\... \.....\..../\\/..\/././\.//.\\\.\\/\\\..\//...
output:
1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 1 1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -...
result:
ok 10000 tokens
Test #10:
score: 3
Accepted
time: 103ms
memory: 1888kb
input:
60 60 X..XXX.../...XXX././X..\..X....XX.X.X./X....XXX....\XXX.X.X. XX..XX.//..XX\.X...X.X...X.....X....
output:
-1 1 1 -1 -1 -1 1 1 1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 1 1 -1 1 1 1 1 -1 -1 1 -1 1 -1 1 -1 -1 1...
result:
ok 14400 tokens
Test #11:
score: 3
Accepted
time: 81ms
memory: 1888kb
input:
60 60 X..XXXX..X...XXX.X.XX..X..XXXXXXX.X.X.XXX.X.XXXX.X.XXXX.XXX. XX..XX.XX..XXX.X...X.X.XXX..X..X....
output:
-1 1 1 -1 -1 -1 -1 1 1 -1 1 1 1 -1 -1 -1 1 -1 1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 -1 -1 -1 1 -1 1 -1 1 -1...
result:
ok 14400 tokens
Test #12:
score: 3
Accepted
time: 249ms
memory: 1624kb
input:
60 60 /..........................................................\ ./..................................
output:
-1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
result:
ok 14400 tokens
Test #13:
score: 3
Accepted
time: 518ms
memory: 1888kb
input:
60 55 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. X\.........XX....X.X...XX../\../...X.....
output:
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
result:
ok 13200 tokens
Test #14:
score: 3
Accepted
time: 494ms
memory: 1892kb
input:
60 60 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. X...\\XXX//../X/////...\..\.\/X.X...
output:
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
result:
ok 14400 tokens
Test #15:
score: 3
Accepted
time: 269ms
memory: 1888kb
input:
60 60 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. X/..\\/..//.././////...\..\.\/......
output:
1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
result:
ok 14400 tokens
Test #16:
score: 0
Wrong Answer
time: 34ms
memory: 10000kb
input:
1000 899 ........X...X..X...X.X.....X.....X...............X.XX.X.X............X..X.X.X..X..............
output:
result:
wrong answer Unexpected EOF in the participants output
Test #17:
score: 0
Wrong Answer
time: 61ms
memory: 10000kb
input:
1000 1000 X.....XXXX.X...X.........X..X.XX...X.XX......X........X..X....X....X.X.......X.......X..XX...
output:
result:
wrong answer Unexpected EOF in the participants output
Test #18:
score: 0
Wrong Answer
time: 152ms
memory: 10004kb
input:
1000 1000 XXX...XXXXXXXXXXXXXX.XXXXXXXXXXXXXXX.XXX.X.XXXXXX.XX..X.XXXXXXXXXXXXXXXXXXXXXX.XXXXX.XXXXX...
output:
result:
wrong answer Unexpected EOF in the participants output
Test #19:
score: 0
Wrong Answer
time: 3ms
memory: 6280kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
result:
wrong answer Unexpected EOF in the participants output
Test #20:
score: 0
Wrong Answer
time: 11ms
memory: 7292kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
result:
wrong answer Unexpected EOF in the participants output
Test #21:
score: 0
Wrong Answer
time: 5ms
memory: 2144kb
input:
1000 1000 ...../\..../.\......//././/./\\./../..\/.......\\.\.....\\\\//.\.../.\....\...\../././../\...
output:
result:
wrong answer Unexpected EOF in the participants output
Test #22:
score: 0
Wrong Answer
time: 5ms
memory: 2144kb
input:
1000 1000 ......\...................../................................................................
output:
result:
wrong answer Unexpected EOF in the participants output
Test #23:
score: 0
Wrong Answer
time: 11ms
memory: 2144kb
input:
1000 1000 /............................................................................................
output:
result:
wrong answer Unexpected EOF in the participants output
Test #24:
score: 0
Wrong Answer
time: 7ms
memory: 1856kb
input:
700 1000 /.............................................................................................
output:
result:
wrong answer Unexpected EOF in the participants output
Test #25:
score: 0
Wrong Answer
time: 12ms
memory: 2148kb
input:
1000 1000 #.....#\/................\..#\#\\/...../.....#..\........#.\..#\...\.\........\/../../...\...
output:
result:
wrong answer Unexpected EOF in the participants output
Test #26:
score: 0
Wrong Answer
time: 14ms
memory: 10000kb
input:
1000 1000 .........X.\........\.......#..X............/#....\........./.............X.......X..........
output:
result:
wrong answer Unexpected EOF in the participants output
Test #27:
score: 0
Wrong Answer
time: 34ms
memory: 10004kb
input:
1000 1000 ...../\\./.X.......X/..../../\.../.X..\X..........\...\..\.X/XX..../.X.....\...X...../XX.....
output:
result:
wrong answer Unexpected EOF in the participants output
Test #28:
score: 0
Wrong Answer
time: 13ms
memory: 7064kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
result:
wrong answer Unexpected EOF in the participants output
Test #29:
score: 0
Wrong Answer
time: 10ms
memory: 8656kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
result:
wrong answer Unexpected EOF in the participants output
Test #30:
score: 0
Wrong Answer
time: 12ms
memory: 7788kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
result:
wrong answer Unexpected EOF in the participants output
Test #31:
score: 0
Wrong Answer
time: 25ms
memory: 10000kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
result:
wrong answer Unexpected EOF in the participants output
Test #32:
score: 0
Wrong Answer
time: 15ms
memory: 6704kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
result:
wrong answer Unexpected EOF in the participants output
Test #33:
score: 0
Wrong Answer
time: 133ms
memory: 10000kb
input:
1000 1000 \.XXX/\X..X\XXXX.XXXXX.X.X.X/X.\XX.XX.\XXX.XXXXX\X\.XX.XX\XX/X.X.XXXXXXXXXXX.X\XXXXXXXXX/....
output:
result:
wrong answer Unexpected EOF in the participants output
Test #34:
score: 0
Wrong Answer
time: 182ms
memory: 10000kb
input:
1000 1000 X..XXXXX.XXXXXXX.XXXXX.X.X.XXXXXXX.XX.XXXX.XXX.XXXXX.X.XXXXXXX.X.XXXXXXX..XX.XXXXXXXXXXX.....
output:
result:
wrong answer Unexpected EOF in the participants output
Test #35:
score: 0
Wrong Answer
time: 148ms
memory: 10004kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
result:
wrong answer Unexpected EOF in the participants output