#include <bits/stdc++.h>
#define ff fflush(stdout)
#define fop(i, l, r) for (int i = l; i <= r; ++i)
#define pof(i, r, l) for (int i = r; i >= l; --i)
#define edg(i, u) for (int i = head[u], v = to[i]; i; i = nxt[i], v = to[i])
typedef long long ll;
typedef unsigned long long ull;
#define int ll
const int inf = 0x3f3f3f3f3f3f3f3fll;
using namespace std;

int read() {
    int x = 0; bool f = 0; char c;
    while (!isdigit(c = getchar())) if (c == '-') f = 1;
    do x = (x << 1) + (x << 3) + (c ^ 48); while (isdigit(c = getchar()));
    return f ? -x : x;
}

const int maxn = 5e5 + 3;

mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
uniform_int_distribution<ull> rd(1, 1e7);
int rd_k = rd(rnd), rd_b = rd(rnd);

struct Hash {
	ull a, b, c, d;
	Hash() = default;
	void init() { a = b = c = d = 0; }
	Hash(ull x) {
		a = x * x * x - (x & 73) + (x ^ 19260817);
		b = (~x) * x + x * 19491001;
		c = rd_k * x + (rd_b ^ x);
		d = rd_k * rd_k * x + rd_b * x;
	}
	friend Hash operator +(const Hash &a, const Hash &b) {
		Hash c; return c.a = a.a + b.a, c.b = a.b + b.b, c.c = a.c + b.c, c.d = a.d + b.d, c;
	}
	void operator +=(const Hash &a) { *this = *this + a; }
	friend Hash operator -(const Hash &a, const Hash &b) {
		Hash c; return c.a = a.a - b.a, c.b = a.b - b.b, c.c = a.c - b.c, c.d = a.d - b.d, c;
	}
	void operator -=(const Hash &a) { *this = *this - a; }
	friend bool operator ==(const Hash &a, const Hash &b) {
		return a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d;
	}
} val[maxn], ori[maxn], sum[maxn], tot, res;

signed main() {
	int n = read(), m = read();
    fop(i, 1, n) val[i] = Hash(rd(rnd)), res += val[i];
    fop(i, 1, m) {
        int u = read(), v = read();
        sum[v] += val[u], ori[v] += val[u], tot += val[u];
    }
    int q = read();
    fop(i, 1, q) {
        int op = read(), u = read();
        if (op == 1) sum[read()] -= val[u], tot -= val[u];
        else if (op == 2) tot -= sum[u], sum[u].init();
        else if (op == 3) sum[read()] += val[u], tot += val[u];
        else tot += ori[u] - sum[u], sum[u] = ori[u];
        puts(tot == res ? "YES" : "NO");
    }
}

原文地址:http://www.cnblogs.com/eafoo/p/16878784.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性