用户输出
Yes
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#63239 | #1037. 膨胀的tyx | Accepted | 100 | 5955 ms | 39540 K | C++ 11 / 1.5 K | 计试001 朱天宇 | 2021-07-20 20:46:13 |
#include <iostream>
#include <queue>
using namespace std;
char a[2001][2001];
int X[2001][2001];
int Y[2001][2001];
bool visited[2001][2001];
int dirx[4] = { -1, 0, 0, 1 };
int diry[4] = { 0, -1, 1, 0 };
struct person {
int x, y;
int bx, by;
person(int fx, int fy, int fbx, int fby) : x(fx), y(fy), bx(fbx), by(fby) {}
};
int main() {
int m, n;
cin >> m >> n;
int flagx = 0, flagy = 0;
queue<person> q;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cin >> a[i][j];
if (a[i][j] == 'S') {
flagx = i;
flagy = j;
}
}
}
person start(flagx, flagy, 0, 0);
q.push(start);
while (!q.empty()) {
person pre = q.front();
q.pop();
for (int i = 0; i < 4; i++) {
int prex = pre.x + dirx[i];
int prey = pre.y + diry[i];
int prebx = pre.bx;
int preby = pre.by;
if (prex < 0) {
prex += m;
prebx--;
} else if (prex >= m) {
prex -= m;
prebx++;
} else if (prey < 0) {
prey += n;
preby--;
} else if (prey >= n) {
prey -= n;
preby++;
}
if (a[prex][prey] == '#')
continue;
if (!visited[prex][prey]) {
visited[prex][prey] = true;
X[prex][prey] = prebx;
Y[prex][prey] = preby;
q.push(person(prex, prey, prebx, preby));
} else if (prebx != X[prex][prey] || preby != Y[prex][prey]) {
cout << "Yes";
return 0;
}
}
}
cout << "No";
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