LCT模板(无讲解)】的更多相关文章

之前一直用的LCT模板,因为其实个人对LCT和Splay不是很熟,所以用起来总觉得略略的坑爹,过了一段时间就忘了,但事实上很多裸的LCT要改的东西是不多的,所以今天写了些注释,以后可能套起模板来会得心应手一点吧- -0 #pragma warning(disable:4996) #include <iostream> #include <cstring> #include <string> #include <cstdio> #include <vec…
这一个月貌似已经考了无数次\(LCT\)了..... 保险起见还是来一发总结吧..... A. LCT 模板 \(LCT\) 是由大名鼎鼎的 \(Tarjan\) 老爷发明的. 主要是用来维护树上路径问题的. 它的神奇之处在于可以直接把一条路径抠出来维护. 其实就是维护树链剖分中的重链与轻链. 网上相关教程很多,直接给板子(其实是我懒得打E_E) 0. Splay代码: \(LCT\)是以\(Splay\) 为实现基础的: IL bool Son(RG int x){return ch[fa[x…
传送门 这是一道LCT的板子题,说白了就是在LCT上支持线段树2的操作. 所以我只是来存一个板子,并不会讲什么(再说我也不会,只能误人子弟2333). 不过代码里的注释可以参考一下. Code #include<bits/stdc++.h> using namespace std; typedef unsigned int uint; ; ; inline int read(){ ,w=;; while(!isdigit(ch)) w|=ch=='-',ch=getchar(); )+(x&l…
P3690 [模板]Link Cut Tree (动态树) 题目背景 动态树 题目描述 给定n个点以及每个点的权值,要你处理接下来的m个操作.操作有4种.操作从0到3编号.点从1到n编号. 0:后接两个整数(x,y),代表询问从x到y的路径上的点的权值的xor和.保证x到y是联通的. 1:后接两个整数(x,y),代表连接x到y,若x到y已经联通则无需连接. 2:后接两个整数(x,y),代表删除边(x,y),不保证边(x,y)存在. 3:后接两个整数(x,y),代表将点x上的权值变成y. 输入输出…
怎么说呢,照着打一遍就自然理解了,再打一遍就会背了,再打一遍就会推了. // luogu-judger-enable-o2 #include<bits/stdc++.h> using namespace std; ; ],val[maxn],ans[maxn],n,m,opt,x,y,z; bool tag[maxn]; ]==x||son[fa[x]][]==x;} ]]^ans[son[x][]]^val[x];} void pushr(int x) { swap(son[x][],son…
想着费马定理和二次探测定理就能随手推了. 做一次是log2n的. #include<bits/stdc++.h> using namespace std; typedef long long int ll; ll T,n; ll qpow(ll x,ll y,ll mod) { ll ans=,base=x; while(y) { )ans=ans*base%mod; base=base*base%mod; y>>=; } return ans; } bool check(ll p…
#include<bits/stdc++.h>//只是在虚数部分改了一下 using namespace std; typedef long long int ll; ; ; ; ; ll n,m,limit,r[maxn*],len,f[maxn],g[maxn]; ll qpow(ll x,ll y) { ll ans=,base=x; while(y) { )ans=ans*base%mod; base=base*base%mod; y>>=; } return ans; }…
#include<bits/stdc++.h> using namespace std; ; const double pi=3.1415926535898; ],len; struct com { double a,b; com(,){a=A,b=B;} void operator=(com x){a=x.a,b=x.b;} com operator+(com x){return com(a+x.a,b+x.b);} com operator-(com x){return com(a-x.a…
推荐几篇比较好的博客: FlashHu 的 讲解比较好 : 传送门 Candy 的 代码~ : 传送门 以及神犇Angel_Kitty的 学习笔记: 传送门 Code V 模板 #include<cstdio> #include<cstring> #include<algorithm> #define rd read() #define ll long long using namespace std; ; ; int n, m; int read() { , p =…
Description 给定N个点以及每个点的权值,要你处理接下来的M个操作. 操作有4种.操作从0到3编号.点从1到N编号. 0:后接两个整数(x,y),代表询问从x到y的路径上的点的权值的xor和. 保证x到y是联通的. 1:后接两个整数(x,y),代表连接x到y,若x到Y已经联通则无需连接. 2:后接两个整数(x,y),代表删除边(x,y),不保证边(x,y)存在. 3:后接两个整数(x,y),代表将点X上的权值变成Y. Input 第1行两个整数,分别为N和M,代表点数和操作数. 第2行…