Code: #include<bits/stdc++.h> using namespace std; #define setIO(s) freopen(s".in","r",stdin) #define maxn 200000 #define inf 10000000000000 #define get(x) (ch[f[x]][1]==x) #define ll long long int root,cc,kk; int h[maxn],ch[maxn…
枚举长度为m的所有段,尝试用中位数更新答案. 所以需要数据结构,支持查询k大,以及大于/小于 k大值 的数的和. 平衡树.权值线段树.权值分块什么的随便呢. #include<cstdio> #include<algorithm> #include<cmath> using namespace std; typedef long long ll; ]; bool operator < (const Point &a,const Point &b){…
题意: Description n列火车,每条有l节车厢.每节车厢有一种颜色(用小写字母表示).有m次车厢交换操作.求:对于每列火车,在交换车厢的某个时刻,与其颜色完全相同的火车最多有多少. Input n l m (2 ≤ n ≤ 1000, 1 ≤ l ≤ 100, 0 ≤ m ≤ 100000) n行字符串,长度为l m行,每行4个数a b c d,a车的第b个字符与c车第d个字符交换. Output n个数,在交换车厢的某个时刻,与该车颜色完全相同的火车最多数目. 题解: 由于$l$很小…
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem 10983 18765 Y 1036 [ZJOI2008]树的统计Count 5293 13132 Y 1588 [HNOI2002]营业额统计 5056 13607 1001 [BeiJing2006]狼抓兔子 4526 18386 Y 2002 [Hnoi2010]Bounce 弹飞绵羊 43…
查最小值,删除,翻转... 显然splay啊... #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #define N 200005 #define inf 0x3f3f3f3f using namespace std; int n; ], fa[N]; int a[N]; int mn[N],zhi[N],size[N]; void push_up(int…