版本比较
题解:P15503 [ICPC 2025 APC] Boarding Queue
正文
增加 6 行删除 6 行
39 行未改动40414243444445464748495051525354545556575859596061626322 行未改动8687888990909192939495969797989910010110110210310410539 行未改动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;}```:::