版本比较
SnackOI R1-C 山峰之上 题解
正文
增加 9 行删除 9 行
42 行未改动43444546474748495051515253545529 行未改动85868788898990919293949595969798991001011021031041041051061071083 行未改动11211311411511611611711811912012012112212212312412512612712812812913013113277 行未改动42 行未改动
int d[4][2] = {1, 0, 0, 1, -1, 0, 0, -1};
struct V { int x, y; int x, y;};
struct node { int x, y, month, water; int x, y, month, water;};
int ans;
29 行未改动 freopen("peak25.out", "w", stdout); #endif std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); std::cout.tie(nullptr);
std::cin >> n >> m; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { std::cin >> a[i][j];
if (a[i][j] == 'R') { river[z++] = {i, j}; } } } for (int i = 1; i <= z; ++i) { std::cin >> l[river[i - 1].first][river[i - 1].second] >> r[river[i - 1].first][river[i - 1].second]; }
for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { for (int k = 1; k <= 12; ++k) { for (int l = 0; l <= 2; ++l) {3 行未改动 } } dis[1][1][1][0] = 1; q.push_back((node){1, 1, 1, 0});
while (!q.empty()) { node now = q.front(); q.pop_front();
int nx = now.x, ny = now.y, nm = now.month, nw = now.water;
if (vis[nx][ny][nm][nw]) { continue; } vis[nx][ny][nm][nw] = 1; //std::cout << "F:" << nx << ' ' << ny << ' ' << nm << ' ' << nw << std::endl;
//stay int tm = next_month(nm); if (a[nx][ny] == 'R' && !check(nx, ny, next_month(nm))) { if (nw < 2 && dis[nx][ny][nm][nw] + 1 < dis[nx][ny][tm][nw + 1]) {77 行未改动