用户输出
Yes
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#4914 | #1037. 膨胀的tyx | Accepted | 100 | 3498 ms | 37368 K | C++ 17 / 2.3 K | LittleFall | 2019-06-27 17:31:57 |
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x3f
#define MAX_INF_VAL 0x3f3f3f3f
using namespace std;
bool good;
int n, m;
char s[2100][2100];
int fuck_x[2100][2100], fuck_y[2100][2100];
int movex[] = { 0, -1, 0, 1 };
int movey[] = { -1, 0, 1, 0 };
queue<pair<int, int> > q;
void dfs(int, int);
int main() {
int x, y;
// for(int k = 1; k <= 17; ++k)
{
// string s1, s2;
// s1.append("data/data"+to_string(k));
// s1.append(".in");
// s2.append("data/data"+to_string(k));
// s2.append(".out");
// freopen(s1.data(), "r", stdin);
// freopen(s2.data(), "w", stdout);
scanf("%d%d", &n, &m);
for (int i = 0; i < n; ++i) {
scanf("%s", s[i]);
// printf("%s\n", s[i]);
for (int j = 0; j < m; ++j) {
fuck_x[i][j] = fuck_y[i][j] = 99999999;
if (s[i][j] == 'S') {
x = i, y = j;
}
}
}
good = false;
while (!q.empty()) q.pop();
fuck_x[x][y] = x, fuck_y[x][y] = y;
dfs(x, y);
if (good)
printf("Yes\n");
else
printf("No\n");
}
}
void dfs(int xx, int yy) {
int x, y;
int nx, ny, rx, ry;
pair<int, int> p;
q.push(make_pair(xx, yy));
while (!q.empty()) {
p = q.front();
q.pop();
x = p.first, y = p.second;
for (int i = 0; !good && i < 4; ++i) {
rx = nx = x + movex[i];
ry = ny = y + movey[i];
rx %= n, ry %= m;
rx += n, ry += m;
rx %= n, ry %= m;
if (s[rx][ry] == '#')
continue;
if (fuck_x[rx][ry] == 99999999) {
fuck_x[rx][ry] = nx;
fuck_y[rx][ry] = ny;
q.push(make_pair(nx, ny));
} else if (fuck_x[rx][ry] != nx || fuck_y[rx][ry] != ny) {
good = true;
return;
}
}
}
}
用户输出
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