用户输出
Yes
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#80738 | #1037. 膨胀的tyx | Accepted | 100 | 5022 ms | 63336 K | C++ 11 (Clang) / 1.6 K | 15291309895 | 2022-08-02 12:07:46 |
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
const int MAX = 4005;
int begx, begy, N, M, bix[MAX][MAX], biy[MAX][MAX];
char maze[MAX][MAX];
bool vis[MAX][MAX];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
struct mov {
int x, y, bx, by;
};
queue<mov> q;
int main() {
cin >> N >> M;
for (int i = 1; i <= N; i++)
for (int j = 1; j <= M; j++) {
cin >> maze[i][j];
if (maze[i][j] == 'S') {
begx = i;
begy = j;
}
}
mov beg;
beg.x = begx;
beg.y = begy;
q.push(beg);
while (!q.empty()) {
mov now = q.front();
q.pop();
for (int i = 0; i < 4; i++) {
mov b = now;
int xx = b.x + dx[i], yy = b.y + dy[i];
if (xx > N) {
xx -= N;
b.bx++;
} else if (xx == 0) {
xx += N;
b.bx--;
} else if (yy > M) {
yy -= M;
b.by++;
} else if (yy == 0) {
yy += M;
b.by--;
}
b.x = xx;
b.y = yy;
if (maze[xx][yy] == '#')
continue;
if (!vis[xx][yy]) {
vis[xx][yy] = 1;
bix[xx][yy] = b.bx;
biy[xx][yy] = b.by;
q.push(b);
} else if (b.bx != bix[xx][yy] || b.by != biy[xx][yy]) {
cout << "Yes" << endl;
return 0;
}
}
}
cout << "No" << endl;
return 0;
}
用户输出
No
系统信息
Exited with return code 0
用户输出
Yes
系统信息
Exited with return code 0
用户输出
No
系统信息
Exited with return code 0
6 20
#.##.##.##.##.##.##.
#.##.##.##.##.##.##.
#.##.##.##.##.##.##.
S.#..#..#..#..#..#..
##..#.
<36 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
用户输出
No
系统信息
Exited with return code 0
2000 2000
S#########################################################################################
<4001910 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
2000 2000
S.........................................................................................
<4001910 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
2000 2000
S.........................................................................................
<4001910 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
2000 2000
S.........................................................................................
<4001910 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
2000 2000
#S########################################################################################
<4001910 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
2000 2000
##########################################################################################
<4001910 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
2000 2000
##########################################################################################
<4001910 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
2000 2000
##########################################################################################
<4001910 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
用户输出
Yes
系统信息
Exited with return code 0
2000 2000
#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.
<4003911 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
2000 2000
#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.
<4003911 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
2000 2000
#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.
<4003911 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
2000 2000
#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.
<4003911 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
2000 2000
#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.
<4003911 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
2000 2000
.#.###.##.#.#.###..#.#.#...##....##...#..#.#......##.###.##.#..##...##...########.###..#.
<4003911 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
2000 2000
.#.###.##.#.#.###..#.#.#...##....##...#..#.#......##.###.##.#..##...##...########.###..#.
<4003911 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
2000 2000
.#.###.##.#.#.###..#.#.#...##....##...#..#.#......##.###.##.#..##...##...########.###..#.
<4003911 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
2000 2000
#.######..##.###..##...#...#.#.#...#.######.#.#######.#...##.#########..#.##.#...##.###.#
<4003911 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
2000 2000
#.######..##.###..##...#...#.#.#...#.######.#.#######.#...##.#########..#.##.#...##.###.#
<4003911 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
2000 2000
#.######..##.###..##...#...#.#.#...#.######.#.#######.#...##.#########..#.##.#...##.###.#
<4003911 bytes omitted>
用户输出
No
系统信息
Exited with return code 0
2000 2000
.#...##...##....#.#....#.#.####..#.....###......##...#....##..##..#######...###.#.#.#...#
<4003911 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
2000 2000
..##.....##..#.#..#..#.#..###....##.....#...#...........#.####......#..##.....###..#.#..#
<4003911 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0
2000 2000
###....#..........#.#.......####..#.#.#.#.##...####..##..##............#..#.##..#.#...##.
<4003911 bytes omitted>
用户输出
Yes
系统信息
Exited with return code 0