AC日记——王室联邦 bzoj 1086】的更多相关文章

Description “余”人国的国王想重新编制他的国家.他想把他的国家划分成若干个省,每个省都由他们王室联邦的一个成员来管理.他的国家有n个城市,编号为1..n.一些城市之间有道路相连,任意两个不同的城市之间有且仅有一条直接或间接的道路.为了防止管理太过分散,每个省至少要有B个城市,为了能有效的管理,每个省最多只有3B个城市.每个省必须有一个省会,这个省会可以位于省内,也可以在该省外.但是该省的任意一个城市到达省会所经过的道路上的城市(除了最后一个城市,即该省省会)都必须属于该省.一个城市可…
4826 思路: 主席树矩阵加减+单调栈预处理: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 200005 #define ll long long #define maxtree maxn*30 class PTreeType { private: ],root[maxn],tot,head[maxn],li[maxn<<],ri[maxn<<],E[maxn<<],cnt,…
3626 思路: 离线操作+树剖: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 #define maxm maxn<<2 #define ll long long #define mod 201314 struct QueryType { int now,id,pos,z; bool operator<(const QueryType pos)const { return now&…
2816 思路: 多个LCT: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 10005 #define ll long long int val[maxn]; struct LinkCutTreeType { ],rev[maxn],sta[maxn],top,cnt[maxn]; void updata(int now) { Max[now]=val[now]; ]) Max[now]=max(Max[now]…
[SCOI2009]游戏 思路: 和为n的几个数最小公倍数有多少种. dp即可: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1005 #define ll long long int n,num; ll dp[maxn][maxn],pi[maxn]; bool if_p[maxn]; void euler(int limit) { ;i<=limit;i++) { if(!if_p[i]) pi[++n…
3572 思路: 虚树+乱搞: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 300005 #define INF 0x3f3f3f3f struct KiType { int id,key; bool operator<(const KiType pos)const { return key<pos.key; } }; struct KiType ki[maxn]; int bel[maxn],dis…
4653 思路: 线段树,指针滑动: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1000005 #define maxm 200005 #define maxn_ maxn<<2 #define INF 0x7fffffff struct TreeNodeType { int l,r,dis,mid,flag; }; struct TreeNodeType tree[maxn_]; struct Q…
3339 思路: 恶心: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 200005 struct TreeNodeType { int l,r,dis,mid,flag; bool if_; }; ]; struct QueryType { int l,r,id; }; s…
1008 思路: 越狱情况=总情况-不越狱情况: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define ll long long ll poww(ll x,ll e,ll k) { ll res=,pos=x;pos%=k; while(e) { ) res=(res*pos)%k; pos=…
1002 思路: 打表找规律: dp[i]=dp[i-1]*3-dp[i-2]+2; 套个高精就a了: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; struct NumberType { int len; ]; void print() { ;i--) putchar(ai[i]+'); } voi…