UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#215480#36. 列队AC_EvilJudgement Failed//C++1018b2025-01-09 18:39:262025-01-09 18:39:28

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
int n, m, Q, a[N][N], b[N][N], rki[N][N], rkj[N][N], pos[N];
int main() {
    scanf("%d%d%d", &n, &m, &Q);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            scanf("%d", &a[i][j]);
    for (int j = 1; j <= m; j++) pos[j] = j;
    for (int i = 1; i <= n; i++) {
        sort(pos + 1, pos + m + 1, [&](int x, int y) { return a[i][x] > a[i][y]; });
        for (int j = 1; j <= m; j++)
            rki[i][pos[j]] = j;
    }
    for (int i = 1; i <= n; i++) pos[i] = i;
    for (int j = 1; j <= m; j++) {
        sort(pos + 1, pos + n + 1, [&](int x, int y) { return a[x][j] > a[y][j]; });
        for (int i = 1; i <= n; i++)
            rkj[pos[i]][j] = i;
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            b[rki[i][j]][rkj[i][j]]++;
    while (Q--) {
        int x, y;
        scanf("%d%d", &x, &y);
        printf("%d\n", b[x][y]);
    }
    return 0;
}

Details

Failed to show details