1 5 5 14 S*#*. .#... ..... ****. ...#...*.P #.*.. ***.. ...*. *.#..
YES
这题很坑竟然会陷入同一地点上方和下方都是传送门的状态,根据题目的意思,上去和下来不消耗时间,那么当出现上下两个传送门所在同一位置,骑士将会变成超级赛亚人,因为传送不消耗时间,他所以将会一直的上下循环传送,因为不消耗时间,所以此时时间会静止,而骑士也会享受此时的装逼时刻,时间都静止了,时间肯定不会流转T这个时刻,公主就不会被吃了,那肯定就是YES了,所以根据我多年菜鸟的猜测,不考虑这种情况会wa。
#include <stdio.h> #include <string.h> #include <queue> #include <iostream> using namespace std; #define inf 0x3f3f3f3f int N, M, T, SUM=0; int px, py, pz; int v[2][15][15]; char Map[2][15][15]; int d[4][2] = {0, 1, 0, -1, 1, 0, -1, 0}; struct step{int x, y, z; }sp[2][15][15]; struct node{int x, y, z;//x代表层,y代表行,z代表列 int step; }pre, nex; int bfs(int x, int y, int z) {queue<node> q;pre.x = x;pre.y = y;pre.z = z;v[x][y][z] = 1;pre.step = 0;q.push(pre);while(!q.empty()) {nex = q.front();q.pop();if(nex.x == px && nex.y == py && nex.z == pz) {return nex.step;}if(Map[nex.x][nex.y][nex.z] == '#' && v[1-nex.x][nex.y][nex.z] == 0) {pre.x = 1-nex.x;pre.y = nex.y;pre.z = nex.z;pre.step = nex.step;v[nex.x][nex.y][nex.z] = 1;v[pre.x][pre.y][pre.z] = 1;Map[pre.x][pre.y][pre.z] = '*';q.push(pre);}for(int i = 0; i < 4; i++) {int dy = d[i][0] + nex.y;int dz = d[i][1] + nex.z;if(dy>=0 && dz>=0 && dy<N && dz<M) {if(Map[nex.x][nex.y][nex.z] != '#')if(Map[nex.x][dy][dz] != '*' && v[nex.x][dy][dz] == 0) {pre.x = nex.x;pre.y = dy;pre.z = dz;pre.step = nex.step+1;v[nex.x][dy][dz] = 1;q.push(pre);}}}}return inf; } int main() {int C;scanf("%d",&C);while(C--) {scanf("%d%d%d",&N,&M,&T);for(int j = 0; j < 2; j++) {for(int i = 0; i < N; i++) {scanf("%s",Map[j][i]);}}for(int i = 0; i < 2; i++) for(int j = 0; j < N; j++) for(int k = 0; k < M; k++) {if(Map[i][j][k] == 'P') {px = i;py = j;pz = k;}else if(Map[i][j][k] == '#' && Map[1-i][j][k] == '#') {Map[i][j][k] = '*';Map[1-i][j][k] = '*';}else if(Map[i][j][k] == '#' && Map[1-i][j][k] == '*') {Map[i][j][k] = '*';}}memset(v, 0, sizeof(v));int step = bfs(0, 0, 0);if(step <= T)printf("YESn");else printf("NOn");}return 0; }
本文发布于:2024-01-27 19:41:53,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/17063557132241.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |