题意: 给出一段序列,每次将从第p个数开始的s个数移到最前面.求最终的序列是什么. 题解: Splay翻转模板题.存下板子. #include <bits/stdc++.h> using namespace std; const int INF = 1e6; ; int n, m; int s, t; int root, sz, tot; ]; int a[N], ans[N]; int get(int x) { ] == x; } void update(int x) { if(x) { s
链接:https://www.nowcoder.com/acm/contest/141/A 来源:牛客网 Eddy was a contestant participating , Eddy failed to solve a physics equation, which pushed him away from a potential medal. Since then on, Eddy found that physics is actually the most important th
题意: 一共有n个宿舍,每个宿舍有4个人.给出第一年的人员分布和第二年的人员分布,问至少有多少人需要移动. 题解: 对于第一年的每个宿舍,向今年的每种组合连边.流量为1,费用为(4 - 组合中已在该宿舍的人数). 最后跑一边费用流. #include <bits/stdc++.h> using namespace std; typedef long long ll; ; const int INF = 0x3f3f3f3f; int n, k; ], y[]; ][]; typedef pai
题意:给你一张无向图,设s(x)为与x直接相连的点的集合,题目中有两种操作: 1:1 l r 将读入的边的序列中第l个到第r个翻转状态(有这条边 -> 没这条边, 没这条边 -> 有这条边) 2:2 x y 询问s(x)和s(y)是否相等. 思路(官方题解):首要问题是怎么快速判断s(x)和s(y)是否相等.我们发现边的翻转操作实际上是异或操作,所以不妨给每个点随机一个值,用与x直接相连的点的异或和作为s(x),这样可以快速判断s(x)和s(y)是否相等.判相等解决了,怎么快速维护操作1呢?我