Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
26915 gaochunzhen 【BJ】T1 C++ 运行超时 20 1000 MS 56796 KB 2018 2024-02-27 13:19:29

Tests(4/20):


#include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 309, M = 9e4 + 9; int n, m, q, type, a[N][N], lstans; int inx[N][N], p[N]; short cnt[N][N][N]; signed main() { scanf("%d%d%d%d", &n, &m, &q, &type); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { scanf("%d", &a[i][j]); } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { inx[i][j] = a[i][j]; } sort(inx[i] + 1, inx[i] + m + 1); p[i] = unique(inx[i] + 1, inx[i] + m + 1) - inx[i] - 1; for (int j = 1; j <= m; j++) { int x = lower_bound(inx[i] + 1, inx[i] + p[i] + 1, a[i][j]) - inx[i]; cnt[i][j][x]++; } for (int j = m - 1; j >= 1; j--) { for (int k = 1; k <= p[i]; k++) { cnt[i][j][k] += cnt[i][j + 1][k]; } } for (int j = 1; j <= m; j++) { for (int k = p[i] - 1; k >= 1; k--) { cnt[i][j][k] += cnt[i][j][k + 1]; } } } while (q--) { int x1, y1, x2, y2, s, t; scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &s, &t); if (type) x1 ^= lstans, y1 ^= lstans, x2 ^= lstans, y2 ^= lstans, s ^= lstans, t ^= lstans; x1 = (x1 - 1 + n) % n + 1, x2 = (x2 - 1 + n) % n + 1, y1 = (y1 - 1 + m) % m + 1, y2 = (y2 - 1 + m) % m + 1; if (x1 > x2) swap(x1, x2); if (y1 > y2) swap(y1, y2); if (s > t) swap(s, t); int ans = 0; for (int i = x1; i <= x2; i++) { int _s = lower_bound(inx[i] + 1, inx[i] + p[i] + 1, s) - inx[i]; int _t = upper_bound(inx[i] + 1, inx[i] + p[i] + 1, t) - inx[i]; // cout << _s << ' ' << _t << endl; ans += (cnt[i][y1][_s] - cnt[i][y1][_t]) - (cnt[i][y2 + 1][_s] - cnt[i][y2 + 1][_t]); } printf("%d\n", lstans = ans); } fclose(stdin); fclose(stdout); return 0; }


测评信息: