UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211408#3803. 激光three_zero3000ms0kbC++112.8kb2024-08-11 11:15:092024-08-11 13:04:58

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[2][2][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);
			if(dp1[2][1][i][j]==0)dfs1(i,j,1,0);
			if(dp1[1][0][i][j]==0)dfs1(i,j,0,-1);
			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: 0
Runtime Error

input:

50 50
.......................#.........#................
..............................................

output:


result:


Test #2:

score: 0
Runtime Error

input:

500 500
...............................................................................................

output:


result:


Test #3:

score: 0
Runtime Error

input:

1000 1000
#.....#..#...............#..#.##......#......#...........#....#....#.#.......#..........##...

output:


result:


Test #4:

score: 0
Runtime Error

input:

990 831
...............................................................................................

output:


result:


Test #5:

score: 0
Runtime Error

input:

1000 1000
.............................................................................................

output:


result:


Test #6:

score: 0
Runtime Error

input:

3 3
/X\
X.X
.X/
1 2 2 3
2 1 3 2

output:


result:


Test #7:

score: 0
Runtime Error

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:


result:


Test #8:

score: 0
Runtime Error

input:

9 10
#./....\..
..../.X..#
/.X..../..
./.\./....
..X../..#.
\/.\...\..
..X...\/..
.X....X..\
....X.....

output:


result:


Test #9:

score: 0
Runtime Error

input:

50 50
.././.\.\\.\\.\/\\.//..\\..//\./////..\//..//\\...
\.....\..../\\/..\/././\.//.\\\.\\/\\\..\//...

output:


result:


Test #10:

score: 0
Runtime Error

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:


result:


Test #11:

score: 0
Runtime Error

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:


result:


Test #12:

score: 0
Runtime Error

input:

60 60
/..........................................................\
./..................................

output:


result:


Test #13:

score: 0
Runtime Error

input:

60 55
.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
X\.........XX....X.X...XX../\../...X.....

output:


result:


Test #14:

score: 0
Runtime Error

input:

60 60
.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
X...\\XXX//../X/////...\..\.\/X.X...

output:


result:


Test #15:

score: 0
Runtime Error

input:

60 60
.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
X/..\\/..//.././////...\..\.\/......

output:


result:


Test #16:

score: 0
Runtime Error

input:

1000 899
........X...X..X...X.X.....X.....X...............X.XX.X.X............X..X.X.X..X..............

output:


result:


Test #17:

score: 0
Runtime Error

input:

1000 1000
X.....XXXX.X...X.........X..X.XX...X.XX......X........X..X....X....X.X.......X.......X..XX...

output:


result:


Test #18:

score: 0
Runtime Error

input:

1000 1000
XXX...XXXXXXXXXXXXXX.XXXXXXXXXXXXXXX.XXX.X.XXXXXX.XX..X.XXXXXXXXXXXXXXXXXXXXXX.XXXXX.XXXXX...

output:


result:


Test #19:

score: 0
Runtime Error

input:

1000 1000
.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:


result:


Test #20:

score: 0
Runtime Error

input:

1000 1000
.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:


result:


Test #21:

score: 0
Runtime Error

input:

1000 1000
...../\..../.\......//././/./\\./../..\/.......\\.\.....\\\\//.\.../.\....\...\../././../\...

output:


result:


Test #22:

score: 0
Runtime Error

input:

1000 1000
......\...................../................................................................

output:


result:


Test #23:

score: 0
Runtime Error

input:

1000 1000
/............................................................................................

output:


result:


Test #24:

score: 0
Runtime Error

input:

700 1000
/.............................................................................................

output:


result:


Test #25:

score: 0
Runtime Error

input:

1000 1000
#.....#\/................\..#\#\\/...../.....#..\........#.\..#\...\.\........\/../../...\...

output:


result:


Test #26:

score: 0
Runtime Error

input:

1000 1000
.........X.\........\.......#..X............/#....\........./.............X.......X..........

output:


result:


Test #27:

score: 0
Runtime Error

input:

1000 1000
...../\\./.X.......X/..../../\.../.X..\X..........\...\..\.X/XX..../.X.....\...X...../XX.....

output:


result:


Test #28:

score: 0
Runtime Error

input:

1000 1000
.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:


result:


Test #29:

score: 0
Runtime Error

input:

1000 1000
.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:


result:


Test #30:

score: 0
Runtime Error

input:

1000 1000
.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:


result:


Test #31:

score: 0
Runtime Error

input:

1000 1000
.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:


result:


Test #32:

score: 0
Runtime Error

input:

1000 1000
.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:


result:


Test #33:

score: 0
Runtime Error

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
Runtime Error

input:

1000 1000
X..XXXXX.XXXXXXX.XXXXX.X.X.XXXXXXX.XX.XXXX.XXX.XXXXX.X.XXXXXXX.X.XXXXXXX..XX.XXXXXXXXXXX.....

output:


result:


Test #35:

score: 0
Runtime Error

input:

1000 1000
.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...

output:


result: