1 条题解

  • 0
    @ 2026-8-21 16:25:21

    #include <bits/stdc++.h> using namespace std; const int N = 1010; int a[N][N]; int n; int op[N], pos[N];

    int main() { cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cin >> a[i][j]; } } for (int i = 1; i <= n; i++) { cin >> op[i] >> pos[i]; if (op[i] == 1) { int c[N], z = 1; for (int j = 1; j <= n; j++) { c[z] = a[pos[i]][j]; z++; } sort(c + 1, c + 1 + n); int v = 1; for (int j = 1; j <= n; j++) { a[pos[i]][j] = c[v]; v++; } } else { int c[N], z = 1; for (int j = 1; j <= n; j++) { c[z] = a[j][pos[i]]; z++; } sort(c + 1, c + 1 + n); int v = 1; for (int j = 1; j <= n; j++) { a[j][pos[i]] = c[v]; v++; } } } int t[N], y[N]; for (int i = 1; i <= n; i++) { cin >> t[i] >> y[i]; cout << a[t[i]][y[i]] << endl; }

    return 0;
    

    }

    • 1

    信息

    ID
    31304
    时间
    1000ms
    内存
    256MiB
    难度
    8
    标签
    递交数
    14
    已通过
    7
    上传者