ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#211416 | #3803. 激光 | three_zero30 | 15 | 5791ms | 72736kb | C++11 | 3.4kb | 2024-08-11 11:32:51 | 2024-08-11 13:09:11 |
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void ts(){cout<<"AKIOI"<<endl;}
int n,m;
int k;
const int N=1005;
char c[N][N];
int dp1[3][3][N][N];
pair<int,int> pa[N][N];
vector<pair<int,int> > mo;
int aa,bb,cc,dd;
bool check=0;
int dfs1(int x,int y,int tx,int ty){
if(dp1[tx+1][ty+1][x+tx][y+ty]>0){
dp1[tx+1][ty+1][x][y]=dp1[tx+1][ty+1][x+tx][y+ty]+1;
return dp1[tx+1][ty+1][x][y];
}
if(c[x+tx][y+ty]=='.'){
dp1[tx+1][ty+1][x][y]=dfs1(x+tx,y+ty,tx,ty)+1;
return dp1[tx+1][ty+1][x][y];
}
if(x+tx>n || x+tx<1 || y+ty>m || y+ty<1 || c[x+tx][y+ty]=='#'){
dp1[tx+1][ty+1][x][y]=1;
return dp1[tx+1][ty+1][x][y];
}
if(c[x+tx][y+ty]=='/'){
int jx,jy;
int sx=x,sy=y;
int stx=tx,sty=ty;
x=x+tx;
y=y+ty;
if(tx==-1 &&ty==0){
jx=0;
jy=1;
}
if(tx==1 && ty==0){
jx=0;
jy=-1;
}
if(tx==0 && ty==1){
jx=-1;
jy=0;
}
if(tx==0 && ty==-1){
jx=1;
jy=0;
}
tx=jx;
ty=jy;
int tmd=dfs1(x,y,tx,ty);
if(c[sx][sy]=='.')dp1[stx+1][sty+1][sx][sy]=tmd+1;
return tmd+1;
}
if(c[x+tx][y+ty]=='\\'){
int jx,jy;
int sx=x,sy=y;
int stx=tx,sty=ty;
x=x+tx;
y=y+ty;
if(tx==-1 &&ty==0){
jx=0;
jy=-1;
}
if(tx==1 && ty==0){
jx=0;
jy=1;
}
if(tx==0 && ty==1){
jx=1;
jy=0;
}
if(tx==0 && ty==-1){
jx=-1;
jy=0;
}
tx=jx;
ty=jy;
int tmd=dfs1(x,y,tx,ty);
if(c[sx][sy]=='.')dp1[stx+1][sty+1][sx][sy]=tmd+1;
return tmd+1;
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>n>>m;
for(register int i=1;i<=n;i++){
for(register int j=1;j<=m;j++){
cin>>c[i][j];
if(c[i][j]=='X')k++;
}
}
for(register int i=1;i<=k/2;i++){
cin>>aa>>bb>>cc>>dd;
pa[aa][bb]=make_pair(cc,dd);
pa[cc][dd]=make_pair(aa,bb);
}
for(register int i=1;i<=n;i++){
for(register int j=1;j<=m;j++){
if(c[i][j]!='.'){
dp1[1][2][i][j]=-1;
dp1[2][1][i][j]=-1;
dp1[0][1][i][j]=-1;
dp1[1][0][i][j]=-1;
continue;
}
if(dp1[1][2][i][j]==0)dfs1(i,j,0,1);
}
}
for(register int i=1;i<=n;i++){
for(register int j=1;j<=m;j++){
if(c[i][j]!='.'){
dp1[1][2][i][j]=-1;
dp1[2][1][i][j]=-1;
dp1[0][1][i][j]=-1;
dp1[1][0][i][j]=-1;
continue;
}
if(dp1[2][1][i][j]==0)dfs1(i,j,1,0);
}
}
for(register int i=1;i<=n;i++){
for(register int j=1;j<=m;j++){
if(c[i][j]!='.'){
dp1[1][2][i][j]=-1;
dp1[2][1][i][j]=-1;
dp1[0][1][i][j]=-1;
dp1[1][0][i][j]=-1;
continue;
}
if(dp1[1][0][i][j]==0)dfs1(i,j,0,-1);
}
}
for(register int i=1;i<=n;i++){
for(register int j=1;j<=m;j++){
if(c[i][j]!='.'){
dp1[1][2][i][j]=-1;
dp1[2][1][i][j]=-1;
dp1[0][1][i][j]=-1;
dp1[1][0][i][j]=-1;
continue;
}
if(dp1[0][1][i][j]==0)dfs1(i,j,-1,0);
}
}
for(register int i=1;i<=n;i++){
for(register int j=1;j<=m;j++){
cout<<dp1[0][1][i][j]<<' ';
}
cout<<endl;
}
for(register int i=1;i<=n;i++){
for(register int j=1;j<=m;j++){
cout<<dp1[2][1][i][j]<<' ';
}
cout<<endl;
}
for(register int i=1;i<=n;i++){
for(register int j=1;j<=m;j++){
cout<<dp1[1][0][i][j]<<' ';
}
cout<<endl;
}
for(register int i=1;i<=n;i++){
for(register int j=1;j<=m;j++){
cout<<dp1[1][2][i][j]<<' ';
}
cout<<endl;
}
return 0;
}
/*
3 3
#..
../
..#
*/
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 3
Accepted
time: 6ms
memory: 9992kb
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: 3
Accepted
time: 74ms
memory: 17532kb
input:
500 500 ...............................................................................................
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 1000000 tokens
Test #3:
score: 3
Accepted
time: 289ms
memory: 25856kb
input:
1000 1000 #.....#..#...............#..#.##......#......#...........#....#....#.#.......#..........##...
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...
result:
ok 4000000 tokens
Test #4:
score: 3
Accepted
time: 209ms
memory: 25736kb
input:
990 831 ...............................................................................................
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 3290760 tokens
Test #5:
score: 3
Accepted
time: 276ms
memory: 25904kb
input:
1000 1000 .............................................................................................
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 4000000 tokens
Test #6:
score: 0
Wrong Answer
time: 4ms
memory: 9200kb
input:
3 3 /X\ X.X .X/ 1 2 2 3 2 1 3 2
output:
-1 -1 -1 -1 0 -1 0 -1 -1 -1 -1 -1 -1 0 -1 1 -1 -1 -1 -1 -1 -1 0 -1 1 -1 -1 -1 -1 -1 -1 0 -...
result:
wrong answer 5th words differ - expected: '7', found: '0'
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 9272kb
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 0 89 3 91 3 89 0 -1 -1 4 -1 4 -1 -1 0 89 5 93 5 89 0 -1 -...
result:
wrong answer 15th words differ - expected: '18', found: '0'
Test #8:
score: 0
Wrong Answer
time: 3ms
memory: 9308kb
input:
9 10 #./....\.. ..../.X..# /.X..../.. ./.\./.... ..X../..#. \/.\...\.. ..X...\/.. .X....X..\ ....X.....
output:
-1 1 -1 1 1 1 1 -1 1 1 1 2 100 2 -1 2 -1 95 2 -1 -1 3 -1 3 90 3 0 -1 3 1 90 -1 0 -1 91 -1 89 4 4 ...
result:
wrong answer 13th words differ - expected: '17', found: '100'
Test #9:
score: 0
Memory Limit Exceeded
input:
50 50 .././.\.\\.\\.\/\\.//..\\..//\./////..\//..//\\... \.....\..../\\/..\/././\.//.\\\.\\/\\\..\//...
output:
result:
Test #10:
score: 0
Wrong Answer
time: 12ms
memory: 10156kb
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:
wrong answer 64th words differ - expected: '58', found: '0'
Test #11:
score: 0
Wrong Answer
time: 8ms
memory: 10156kb
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:
wrong answer 64th words differ - expected: '99', found: '0'
Test #12:
score: 0
Wrong Answer
time: 3ms
memory: 10324kb
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:
wrong answer 61st words differ - expected: '3542', found: '3571'
Test #13:
score: 0
Wrong Answer
time: 4ms
memory: 10160kb
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:
wrong answer 58th words differ - expected: '3216', found: '0'
Test #14:
score: 0
Memory Limit Exceeded
input:
60 60 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. X...\\XXX//../X/////...\..\.\/X.X...
output:
result:
Test #15:
score: 0
Memory Limit Exceeded
input:
60 60 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. X/..\\/..//.././////...\..\.\/......
output:
result:
Test #16:
score: 0
Wrong Answer
time: 572ms
memory: 25856kb
input:
1000 899 ........X...X..X...X.X.....X.....X...............X.XX.X.X............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 1 1 1 1 1 1...
result:
wrong answer 908th words differ - expected: '239', found: '0'
Test #17:
score: 0
Wrong Answer
time: 386ms
memory: 25860kb
input:
1000 1000 X.....XXXX.X...X.........X..X.XX...X.XX......X........X..X....X....X.X.......X.......X..XX...
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 ...
result:
wrong answer 1007th words differ - expected: '1301', found: '0'
Test #18:
score: 0
Wrong Answer
time: 435ms
memory: 25856kb
input:
1000 1000 XXX...XXXXXXXXXXXXXX.XXXXXXXXXXXXXXX.XXX.X.XXXXXX.XX..X.XXXXXXXXXXXXXXXXXXXXXX.XXXXX.XXXXX...
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...
result:
wrong answer 1011th words differ - expected: '2203', found: '0'
Test #19:
score: 0
Wrong Answer
time: 424ms
memory: 25904kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
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:
wrong answer 1002nd words differ - expected: '420525', found: '0'
Test #20:
score: 0
Wrong Answer
time: 303ms
memory: 25904kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
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:
wrong answer 1002nd words differ - expected: '1000', found: '0'
Test #21:
score: 0
Memory Limit Exceeded
input:
1000 1000 ...../\..../.\......//././/./\\./../..\/.......\\.\.....\\\\//.\.../.\....\...\../././../\...
output:
result:
Test #22:
score: 0
Memory Limit Exceeded
input:
1000 1000 ......\...................../................................................................
output:
result:
Test #23:
score: 0
Wrong Answer
time: 398ms
memory: 72736kb
input:
1000 1000 /............................................................................................
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:
wrong answer 1001st words differ - expected: '999002', found: '999501'
Test #24:
score: 0
Wrong Answer
time: 240ms
memory: 43824kb
input:
700 1000 /.............................................................................................
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:
wrong answer 1001st words differ - expected: '489302', found: '489651'
Test #25:
score: 0
Memory Limit Exceeded
input:
1000 1000 #.....#\/................\..#\#\\/...../.....#..\........#.\..#\...\.\........\/../../...\...
output:
result:
Test #26:
score: 0
Memory Limit Exceeded
input:
1000 1000 .........X.\........\.......#..X............/#....\........./.............X.......X..........
output:
result:
Test #27:
score: 0
Memory Limit Exceeded
input:
1000 1000 ...../\\./.X.......X/..../../\.../.X..\X..........\...\..\.X/XX..../.X.....\...X...../XX.....
output:
result:
Test #28:
score: 0
Wrong Answer
time: 305ms
memory: 25960kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
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:
wrong answer 1002nd words differ - expected: '964933', found: '0'
Test #29:
score: 0
Wrong Answer
time: 312ms
memory: 25944kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
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:
wrong answer 1002nd words differ - expected: '1000', found: '0'
Test #30:
score: 0
Wrong Answer
time: 281ms
memory: 25960kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
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:
wrong answer 1002nd words differ - expected: '886109', found: '0'
Test #31:
score: 0
Memory Limit Exceeded
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
result:
Test #32:
score: 0
Memory Limit Exceeded
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
output:
result:
Test #33:
score: 0
Memory Limit Exceeded
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:
Test #34:
score: 0
Wrong Answer
time: 476ms
memory: 25860kb
input:
1000 1000 X..XXXXX.XXXXXXX.XXXXX.X.X.XXXXXXX.XX.XXXX.XXX.XXXXX.X.XXXXXXX.X.XXXXXXX..XX.XXXXXXXXXXX.....
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 ...
result:
wrong answer 1006th words differ - expected: '835', found: '0'
Test #35:
score: 0
Wrong Answer
time: 771ms
memory: 25860kb
input:
1000 1000 .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
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:
wrong answer 1003rd words differ - expected: '999506', found: '0'