版本比较
题解:P15503 [ICPC 2025 APC] Boarding Queue
正文
增加 6 行删除 6 行
39 行未改动40414243444546474849505152535455565758596061626322 行未改动868788899091929394959697989910010110210310410539 行未改动pair<int, int> w[N * N];void solution() {cin >> r >> c >> n >> p;// 输入网格并记录每个非零数字的位置for (int i = 1; i <= r; i++) {for (int j = 1; j <= c; j++) {cin >> f[i][j];if (f[i][j] != 0) {w[f[i][j]] = {i, j};}}}// 从p开始向前遍历for (int i = p; i >= 1; i--) {int t = p - i;int x = w[i].first, y = w[i].second;// 检查四个方向// 左边if (y - 1 >= 1 && f[x][y - 1] && f[x][y - 1] + t <= n) {if (!v[f[x][y - 1] + t]) {22 行未改动v[f[x + 1][y] + t] = 1;}}}cout << cnt << "/" << n - 1;}signed main() {ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);int T = 1;// cin >> T;while (T--) solution();return 0;}```:::39 行未改动40414243444546474849505152535455565758596061626322 行未改动868788899091929394959697989910010110210310410539 行未改动pair<int, int> w[N * N];void solution() {cin >> r >> c >> n >> p;// 输入网格并记录每个非零数字的位置for (int i = 1; i <= r; i++) {for (int j = 1; j <= c; j++) {cin >> f[i][j];if (f[i][j] != 0) {w[f[i][j]] = {i, j};}}}// 从p开始向前遍历for (int i = p; i >= 1; i--) {int t = p - i;int x = w[i].first, y = w[i].second;// 检查四个方向// 左边if (y - 1 >= 1 && f[x][y - 1] && f[x][y - 1] + t <= n) {if (!v[f[x][y - 1] + t]) {22 行未改动v[f[x + 1][y] + t] = 1;}}}cout << cnt << "/" << n - 1;}signed main() {ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);int T = 1;// cin >> T;while (T--) solution();return 0;}```:::