ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#215480 | #36. 列队 | AC_Evil | Judgement Failed | / | / | C++ | 1018b | 2025-01-09 18:39:26 | 2025-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;
}
详细
Failed to show details