跳到正文

剪贴板

剪贴板 5lj5uo64

原文
剪贴板信息

剪贴板信息

收录
更新

主页被JC了主页被 J C了

以至于发生物种之间的转变

代码
     |
     V
  /l、
 (o. O 7
 l、 ~ヽ      < -- 已实现从各个方面的退化
 じしf_, )ノ

有事找 Ta:

友链


第一道珂朵莉的题:\color{MidnightBlue}第一道珂朵莉的题: 纵使日薄西山\color{Turquoise}纵使日薄西山

我很喜欢的题:\color{MidnightBlue}我很喜欢的题:P5314\color{Turquoise}P5314

第一场AK⁡的Luogu⁡赛\color{MidnightBlue}第一场 \operatorname{AK} 的 \operatorname{Luogu} 赛:【LGR−192−Div.3】洛谷基础赛\color{Turquoise}{【LGR-192-Div.3】洛谷基础赛}

2024.7.13 打卡100天祭\color{MidnightBlue}2024.7.13 \ 打卡 100 天祭


这个人迟早该退了\color{Fuchsia}这个人迟早该退了


颜色表颜色表

图论神器图论神器

DesmosDesmos

Fread/FwriteFread / Fwrite

优美的常用板子优美的常用板子

CodingOIer′s洛谷工具站CodingOIer's 洛谷工具站

猫猫猫猫

优雅地上VSCode优雅地上 VS Code

ClashClash

篡改猴篡改猴

FireFoxInsertFireFoxInsert

电磁炮电磁炮

天上的一朵云天上的一朵云

Namerena FlarumNamerena\ Flarum

优美的求因数个数优美的求因数个数

CSP−S初赛题解CSP - S 初赛题解

背包

模板

C++
#include<bits/stdc++.h>
#define int long long
#define Maxn 1000005
using namespace std;
struct BCJ {
	int f[Maxn];
	int find(int x) {
		return x == f[x]?x:f[x] = find(f[x]);
	}
};
struct FHQ {
	int val[Maxn],lson[Maxn],rson[Maxn],prio[Maxn],rt[Maxn],sz[Maxn],key[Maxn]/*原编号*/,cnt[Maxn],tot;
	const int inf = INT_MAX;
	void pushup(int x) {
		sz[x] = sz[lson[x]]+sz[rson[x]]+cnt[x];
	}
	void split(int now,int bound,int &x,int &y) {
		if(!now)return x = y = 0,void();
		if(val[now] <= bound) {
			x = now;
			split(rson[now],bound,rson[now],y);
		} else {
			y = now;
			split(lson[now],bound,x,lson[now]);
		} pushup(now);
	}
	int Merge(int x,int y) {
		if(!x||!y)return x|y;
		if(prio[x] < prio[y]) {
			rson[x] = Merge(rson[x],y);
			pushup(x);
			return x;
		} else {
			lson[y] = Merge(x,lson[y]);
			pushup(y);
			return y;
		}
	}
	int NewNote(int k,int res,int id) {
		sz[++tot] = 1;
		key[tot] = id;
		cnt[tot] = res;
		val[tot] = k;
		prio[tot] = rand();
		return tot;
	}
	void Merge0(int x,int s) {
		if(!x)return ;
		Insert(s,val[x],cnt[x],key[x]);
		dfs(lson[x],s);dfs(rson[x],s);
	}
	void Deleten(int &y,int res) {
		if(cnt[y] > res)cnt[y] -= res;
		else res -= cnt[y],y = Merge(lson[y],rson[y]),Deleten(y,res);
	}
	void Insert(int s,int k,int res,int id) { // 插入
		int x,y = NewNote(k,res,id),z;
		split(rt[s],k,x,z);
		rt[s] = Merge(x,Merge(y,z));
	}
	void Delete(int s,int k,int res) { // 删除
		int x,y,z;
		split(rt[s],k,y,z);
		split(rt[s],k-1,x,y);
		Deleten(y,res);
		rt[s] = Merge(x,Merge(y,z));
	}
	int Rank(int x,int k) { // 第 k 小
	  if(!x)return -1;
	  if(k <= sz[lson[x]])return Rank(lson[x],k);
	  if(k <= sz[lson[x]]+cnt[x])return key[x];
	  return Rank(rson[x],k-sz[lson[x]]-cnt[x]);
	}
  int find_rank(int x,int k) {
    if(!x)return -1;
    if(val[x] == k)return sz[lson[x]]+1;
    if(k <= val[lson[x]])return find_rank(lson[x],k);
    return find_rank(rson[x],k)+sz[lson[x]]+cnt[x];
  }
	int pre(int s,int x) { // 前驱
		int cur = rt[s],lst;
		while(cur) {
		    if(val[cur] < x)lst = cur,cur = rson[cur];
		    else cur = lson[cur];
		} return lst;
	}
	int suf(int s,int x) { // 后继
		int cur = rt[s],lst;
		while(cur) {
		  	if(val[cur] > x)lst = cur,cur = lson[cur];
		    else cur = rson[cur];
		} return lst;
	}
	void QFS_Merge(int x,int y) { // 启发式合并
		if(sz[rt[x]] > sz[rt[y]])
			sap(x,y);
		Merge0(rt[x],y);
	}
};
signed main()
{
	return 0;
 }