这个题,做出来的人很多,我感觉是数据不够强,我看了很多人的代码直接暴力也能过了,直接暴力如果数据够强的话肯定是时间超限,边缘数据不够强。如果和上次一样估计很多人的E会GG。我看到一位OIdalao的代码,认为这个是正确的解法,对每一道围墙进行hash处理,然后用二维的树状数组来解决这个问题。感觉博主已经写得简单易懂了。长了姿势
#include <bits/stdc++.h>using namespace std;map<pair<pair<int, int>, pair<int, int> >, int>g;int n, m, q;long long c[2520][2520];void R(int x, int y, long long z) {for (int i = x; i <= n; i += i & -i) {for (int j = y; j <= m; j += j & -j) {c[i][j] += z;}}}long long G(int x, int y) {long long re = 0;for (int i = x; i > 0; i -= i & -i) {for (int j = y; j > 0; j -= j & -j) {re += c[i][j];}}return re;}int rd() {return rand() << 15 | rand();}int main() {scanf("%d%d%d", &n, &m, &q);srand(time(0));for (int i = 0; i < 011; i++) {srand(rd());}for (int i = 0; i < q; i++) {int o, xa, xb, ya, yb;scanf("%d%d%d%d%d", &o, &xa, &ya, &xb, &yb);if (o == 1) {int u = rd();g[make_pair(make_pair(xa, ya), make_pair(xb, yb))] = u;R(xa, ya, u);R(xa, yb + 1, -u);R(xb + 1, ya, -u);R(xb + 1, yb + 1, u);} else if (o == 2) {int u = g[make_pair(make_pair(xa, ya), make_pair(xb, yb))];R(xa, ya, -u);R(xa, yb + 1, u);R(xb + 1, ya, u);R(xb + 1, yb + 1, -u);} else {long long va = G(xa, ya);long long vb = G(xb, yb);if (va == vb) {printf("Yes\n");} else {printf("No\n");}}}return 0;}