用户输出
Yes
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#72153 | #1037. 膨胀的tyx | Accepted | 100 | 3284 ms | 47484 K | C++ 11 / 3.5 K | q3540555 | 2022-06-30 15:52:07 |
/*#include <iostream>
#include <map>
#include <utility>
using namespace std;
bool success = 0;
int n, m;
int matrix[2000][2000];
pair<int, int> t0, t, t1;
map<pair<int, int>, pair<int, int>> res;
void Search(int x, int y, int rx, int ry);
int main(int argc, char** argv, char** env) {
char tmp;
cin >> n >> m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin.get(tmp);
while (tmp == ' ' || tmp == '\n') cin.get(tmp);
if (tmp == '#') {
matrix[i][j] = 0;
continue;
}
matrix[i][j] = 1;
if (tmp == 'S') {
t.first = i, t.second = j;
}
}
}
Search(t.first % n, t.second % m, t.first, t.second);
if (success) {
cout << "Yes";
return 0;
}
cout << "No";
return 0;
}
void Search(int x, int y, int rx, int ry) {
if (matrix[x][y] == 0 || success)
return;
t.first = x, t.second = y, t1.first = rx, t1.second = ry;
if (res[t] == t0)
res[t] = t1;
else if (res[t] != t1) {
success = 1;
return;
} else
return;
Search((x + 1) % n, y, rx + 1, ry);
if (x - 1 >= 0)
Search((x - 1) % n, y, rx - 1, ry);
else
Search((x - 1) % n + n, y, rx - 1, ry);
Search(x, (y + 1) % m, rx, ry + 1);
if (y - 1 >= 0)
Search(x, (y - 1) % m, rx, ry - 1);
else
Search(x, (y - 1) % m + m, rx, ry - 1);
}*/
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define spause() system("pause")
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> prdd;
const int dinf = 0x7fffffff;
const llong llinf = 0x7fffffffffffffff;
const int way[4][2] = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } };
struct cao {
bool vd;
int dx = dinf, dy = dinf;
};
int n, m, ans = 0;
vector<prdd> bfsn, tmp;
cao ecao[2000][2000];
int pmd(int a, int p) {
int ans = a % p;
if (ans < 0)
ans += p;
return ans;
}
void bfsnp(prdd p) {
for (int i = 0; i < 4; i++) {
int nl = p.first + way[i][0], nr = p.second + way[i][1];
if (!ecao[pmd(nl, n)][pmd(nr, m)].vd)
continue;
int nx = ecao[p.first][p.second].dx, ny = ecao[p.first][p.second].dy;
if (nl < 0 || nr < 0 || nl >= n || nr >= m) {
nx += way[i][0];
ny += way[i][1];
}
if (ecao[pmd(nl, n)][pmd(nr, m)].dx == dinf) {
tmp.push_back(prdd(pmd(nl, n), pmd(nr, m)));
ecao[pmd(nl, n)][pmd(nr, m)].dx = nx;
ecao[pmd(nl, n)][pmd(nr, m)].dy = ny;
} else if (nx != ecao[pmd(nl, n)][pmd(nr, m)].dx || ny != ecao[pmd(nl, n)][pmd(nr, m)].dy) {
bfsn.clear();
tmp.clear();
ans++;
}
}
}
int main() {
cin.sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) {
char tmp;
cin >> tmp;
if (tmp == '#')
ecao[i][j].vd = false;
else
ecao[i][j].vd = true;
if (tmp == 'S') {
ecao[i][j].dx = ecao[i][j].dy = 0;
bfsn.push_back(prdd(i, j));
}
}
while (!bfsn.empty()) {
for (int i = 0; i < bfsn.size(); i++) bfsnp(bfsn.at(i));
bfsn = tmp;
tmp.clear();
}
if (ans)
printf("Yes");
else
printf("No");
spause();
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