版本比较
P11353 [NOISG 2024 Finals] Field
正文
增加 6 行删除 6 行
51 行未改动52535455565758596088 行未改动1491501511521531541551561571581591601611621631641651661671681698 行未改动51 行未改动int x = tmp.x, y = tmp.y, t = tmp.t;if (vis[x][y][t]) continue;vis[x][y][t] = 1;auto chkupd = [&](int tx, int ty, int tt, int ww) {if (!ban[tx][ty] && dist[tx][ty][tt] > dist[x][y][t] + ww)Q.push((node) { tx, ty, tt, dist[tx][ty][tt] = dist[x][y][t] + ww });};if (t == 0) {if (x != 1) chkupd(x - 1, y, 1, 1);88 行未改动y2 = lower_bound(d_y + 1, d_y + dycnt + 1, rect[i][3] + 1) - d_y;++ban[x1][y1], --ban[x2][y1], --ban[x1][y2], ++ban[x2][y2];}for (int i = 1; i <= dxcnt; i++) {for (int j = 1; j <= dycnt; j++)ban[i][j] += ban[i - 1][j] + ban[i][j - 1] - ban[i - 1][j - 1];}_dijkstra();if (tp == 1) {while (q--) {int x = read(), y = read(), tx, ty, ans;tx = upper_bound(d_x + 1, d_x + dxcnt + 1, x) - d_x - 1;ty = upper_bound(d_y + 1, d_y + dycnt + 1, y) - d_y - 1;ans = min({dist[tx][ty][0] + x - d_x[tx] + d_y[ty + 1] - y - 1,dist[tx][ty][1] + d_x[tx + 1] - x - 1 + d_y[ty + 1] - y - 1,dist[tx][ty][2] + x - d_x[tx] + y - d_y[ty],dist[tx][ty][3] + d_x[tx + 1] - x - 1 + y - d_y[ty]});cout << (ans >= inf ? -1 : ans) << "\n";}8 行未改动51 行未改动52535455565758596088 行未改动1491501511521531541551561571581591601611621631641651661671681698 行未改动51 行未改动int x = tmp.x, y = tmp.y, t = tmp.t;if (vis[x][y][t]) continue;vis[x][y][t] = 1;auto chkupd = [&](int tx, int ty, int tt, int ww) {if (!ban[tx][ty] && dist[tx][ty][tt] > dist[x][y][t] + ww)Q.push((node) { tx, ty, tt, dist[tx][ty][tt] = dist[x][y][t] + ww });};if (t == 0) {if (x != 1) chkupd(x - 1, y, 1, 1);88 行未改动y2 = lower_bound(d_y + 1, d_y + dycnt + 1, rect[i][3] + 1) - d_y;++ban[x1][y1], --ban[x2][y1], --ban[x1][y2], ++ban[x2][y2];}for (int i = 1; i <= dxcnt; i++) {for (int j = 1; j <= dycnt; j++)ban[i][j] += ban[i - 1][j] + ban[i][j - 1] - ban[i - 1][j - 1];}_dijkstra();if (tp == 1) {while (q--) {int x = read(), y = read(), tx, ty, ans;tx = upper_bound(d_x + 1, d_x + dxcnt + 1, x) - d_x - 1;ty = upper_bound(d_y + 1, d_y + dycnt + 1, y) - d_y - 1;ans = min({dist[tx][ty][0] + x - d_x[tx] + d_y[ty + 1] - y - 1,dist[tx][ty][1] + d_x[tx + 1] - x - 1 + d_y[ty + 1] - y - 1,dist[tx][ty][2] + x - d_x[tx] + y - d_y[ty],dist[tx][ty][3] + d_x[tx + 1] - x - 1 + y - d_y[ty]});cout << (ans >= inf ? -1 : ans) << "\n";}8 行未改动