版本比较
SnackOI R1-C 山峰之上 题解
正文
增加 9 行删除 9 行
42 行未改动4344454647484950515253545529 行未改动8586878889909192939495969798991001011021031041051061071083 行未改动11211311411511611711811912012112212312412512612712812913013113277 行未改动42 行未改动int d[4][2] = {1, 0, 0, 1, -1, 0, 0, -1};struct V {int x, y;};struct node {int x, y, month, water;};int ans;29 行未改动freopen("peak25.out", "w", stdout);#endifstd::ios::sync_with_stdio(false);std::cin.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;//stayint 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 行未改动42 行未改动4344454647484950515253545529 行未改动8586878889909192939495969798991001011021031041051061071083 行未改动11211311411511611711811912012112212312412512612712812913013113277 行未改动42 行未改动int d[4][2] = {1, 0, 0, 1, -1, 0, 0, -1};struct V {int x, y;};struct node {int x, y, month, water;};int ans;29 行未改动freopen("peak25.out", "w", stdout);#endifstd::ios::sync_with_stdio(false);std::cin.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;//stayint 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 行未改动