标签:ble cpp fine ring void stat false null sed
分块+并查集,大板子,没了。
并查集不路径压缩,可撤销,然后暴力删除
这样对于每个块都是独立的,所以直接搞就行了。
然后块内修改操作搞掉,就是单独的了
// powered by c++11
// by Isaunoya
#include
#define rep(i, x, y) for (register int i = (x); i = (y); --i)
using namespace std;
using db = double;
using ll = long long;
using uint = unsigned int;
// #define int long long
using pii = pair;
#define ve vector
#define Tp template
#define all(v) v.begin(), v.end()
#define sz(v) ((int)v.size())
#define pb emplace_back
#define fir first
#define sec second
// the cmin && cmax
Tp void cmax(T& x, const T& y) {
if (x void cmin(T& x, const T& y) {
if (x > y) x = y;
}
// sort , unique , reverse
Tp void sort(ve& v) { sort(all(v)); }
Tp void unique(ve& v) {
sort(all(v));
v.erase(unique(all(v)), v.end());
}
Tp void reverse(ve& v) { reverse(all(v)); }
const int SZ = 0x191981;
struct FILEIN {
~FILEIN() {}
char qwq[SZ], *S = qwq, *T = qwq, ch;
char GETC() { return (S == T) && (T = (S = qwq) + fread(qwq, 1, SZ, stdin), S == T) ? EOF : *S++; }
FILEIN& operator>>(char& c) {
while (isspace(c = GETC()))
;
return *this;
}
FILEIN& operator>>(string& s) {
while (isspace(ch = GETC()))
;
s = ch;
while (!isspace(ch = GETC())) s += ch;
return *this;
}
Tp void read(T& x) {
bool sign = 1;
while ((ch = GETC()) 0x2f) x = x * 0xa + (ch ^ 0x30);
x = sign ? x : -x;
}
FILEIN& operator>>(int& x) { return read(x), *this; }
// FILEIN& operator>>(signed& x) { return read(x), *this; }
FILEIN& operator>>(unsigned& x) { return read(x), *this; }
} in;
struct FILEOUT {
const static int LIMIT = 0x114514;
char quq[SZ], ST[0x114];
signed sz, O;
~FILEOUT() { flush(); }
void flush() {
fwrite(quq, 1, O, stdout);
fflush(stdout);
O = 0;
}
FILEOUT& operator LIMIT) flush();
for (char c : str) quq[O++] = c;
return *this;
}
Tp void write(T x) {
if (O > LIMIT) flush();
if (x b;
struct Edge {
int u, v, w;
} e[maxn];
struct Que {
int op, x, y;
} Q[maxn];
struct Qry {
int id, u, v, w;
bool operator other.w;
return id qr;
struct DSU {
int n, fa[maxn], sz[maxn], top, sta[maxn], stb[maxn];
inline void reset(int _n) {
n = _n, top = 0;
for (int i = 1; i = l; i--) {
if (Q[i].op == 1) {
if (!vis[Q[i].x]) {
vis[Q[i].x] = 1;
if (Q[i].y >= x.w) {
dsu.merge(e[Q[i].x].u, e[Q[i].x].v, 1);
}
}
}
}
for (auto y : b) {
if (!vis[y] && e[y].w >= x.w) {
dsu.merge(e[y].u, e[y].v, 1);
}
}
ans[x.id] = dsu.getsize(x.u);
for (auto y : b) {
vis[y] = 0;
}
dsu.reset();
}
for (int i = l; i > n >> m;
for (int i = 1; i > u >> v >> w;
e[i] = { u, v, w };
}
in >> num;
len = 900;
for (int i = 1; i > Q[i].op >> Q[i].x >> Q[i].y;
}
for (int i = 1; i
P5443 [APIO2019]桥梁 [分块+并查集]
标签:ble cpp fine ring void stat false null sed
原文地址:https://www.cnblogs.com/Isaunoya/p/12310916.html