08 2021 档案
摘要:https://acm.hdu.edu.cn/showproblem.php?pid=7068 对于一个数,最大得分时要加上b[1],最小得分加上b[n]. 寻找最大排名,要对每个b[2->n]匹配一个a[y],使尽可能多的和小于b[1] + a[x] 显然从小到大枚举b[i],依次在a中找即可 c
阅读全文
摘要:https://acm.hdu.edu.cn/showproblem.php?pid=7072 deque 模拟下每次加入数删除数即可,记录数是否被删除,数在左que还是右que,que中没被删除的数的个数 const int maxn = 2e7 + 7; int n, t, m, x, sizl
阅读全文
摘要:https://acm.hdu.edu.cn/showproblem.php?pid=7067 分情况讨论,k=1,k为奇数,k为偶数 特判第一个人直接不玩的情况即可 const int maxn = 1e5 + 7; #define int long long int n, t, m, k; ve
阅读全文
摘要:https://codeforces.com/contest/1506/problem/G 用单调栈维护拿的字母即可 const int maxn = 1e3 + 7; int n, t, m, cnt[300]; string s; void solve() { cin >> t; while (
阅读全文
摘要:https://acm.hdu.edu.cn/showproblem.php?pid=7064 注意开数组的大小 注意优化(插入的时候判断长度是否可行) const int maxn = 1e5 + 7; int n, t, m, stp = 30; int nex[maxn * 33][27],
阅读全文
摘要:https://acm.hdu.edu.cn/showproblem.php?pid=7059 可以将每段区间的和转换成最高位的和+其他位的和. 查询 sum = lsum + rsum 减: 每个节点最多有三十次减操作,类似sqrt那个题目,直接在l==r的时候单点修改,注意需要判断当前能否减的条
阅读全文
摘要:区间修改 #define int long long const int maxn = 3e5 + 7; int a[maxn]; struct node { int l, r, sum, lz; } tr[maxn << 4]; void push_up(int p) { tr[p].sum =
阅读全文
摘要:https://www.luogu.com.cn/problem/P3674 a - b = x 可以转换成 a = b + x.用bitset记录区间数的种类,存在a - b = x 等价于 bitset & bitset<<x 是否有1 a + b = x 可以记b = N - B,也就是判断
阅读全文
摘要:https://acm.hdu.edu.cn/showproblem.php?pid=7055 ##思路1 考虑dp结果,dp[i]表示以i为结尾的答案 每次新进入一个字符,计算其对答案产生的贡献 char s[maxn]; int t, cnt[30], sum[30]; ll dp[maxn];
阅读全文
摘要:https://codeforces.com/contest/1557/problem/D 线段树维护dp + dp路径记录 + 离散化 考虑最多能保留的个数,线段树维护相邻两层间转移的1的位置的最大值. 对每层考虑,新加进来一个线段,都会产生一个非负的贡献,每次转移都要询问这一层能向上转移的每个点
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/11259/F 用bitset滚动记录每个点能到达的其他点.暴力,n4/32 每次转移的时候. 如果这个点是'0', 如果右边点为'0', 就|=右边点能到达的点 如果右边点为'1'... 如果这个点为'1' reset这个点(
阅读全文
摘要:莫队 普通莫队 注意顺序正确!! codes for (int i = 1; i <= m; i++) { int pl = q[i].l, pr = q[i].r; while (l > pl) add(a[--l]); while (r < pr) add(a[++r]); while (l <
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/11258/F 对两颗树分别考虑. 对于第一颗树,考虑对每条链上双指针选择连续的节点(显然只有在同一条链上的点才能互为),用deque维护方便 对于第二颗树,n个点选择k个点互不为祖先,可以树剖+线段树维护,每次选择一个节点后对
阅读全文
摘要:https://codeforces.com/contest/1555/problem/E 比赛中板子错了 心态炸裂 (比正解多了个二分 对了也是tle 但是 显然可以不用二分 直接双指针瞎搞,按区间长度排序,双指针r就+1,l就-1. const int maxn = 1e6 + 7; int n
阅读全文
摘要:https://acm.hdu.edu.cn/showproblem.php?pid=6998 考虑每次操作能对答案产生的影响 记每次操作为$swap(a,b)$,dp[i]表示答案,初始化位-1表示状态不可达,开始时dp[k] = 0. a不可达 b可达 dp[v] = dp[u], dp[u]
阅读全文
摘要:https://codeforces.ml/contest/1469/problem/D 显然,容易构造n+20步完成.而在多出5步的情况下考虑每次保留sqrt(n) 按照下面进行构造: \([1,2,3,4,5,6,7,8,9] to [1,2,3,1,1,1,1,1,9] to [1,2,3,1
阅读全文
摘要:https://codeforces.com/contest/1168/problem/C 考虑$dp$,$dp[i][j]$表示从i开始最先到达的第j位为1的位置 如果$a[x]$能转移到$a[y]$那么必定有一位二进制位置上,\(dp[x][k]<=y\) $dp$转移:从$n$向$1$枚举$i
阅读全文
摘要:https://codeforces.com/contest/1313/problem/C2 单调栈维护下每个位置向前向后单调的最大和 const int maxn = 5e5 + 7; #define int long long int n, t, m; int a[maxn], pre[maxn
阅读全文
摘要:#bitmasks https://codeforces.com/contest/1469/problem/E https://codeforces.com/contest/1168/problem/C 考虑$dp$,$dp[i][j]$表示从i开始最先到达的第j位为1的位置 如果$a[x]$能转移
阅读全文
摘要:构造 位运算构造 ?? 平方构造 https://codeforces.ml/contest/1469/problem/D
阅读全文
摘要:树链剖分 + 线段树 模板 const int maxn = 1e5 + 7; #define ls(x) (x << 1) #define rs(x) (x << 1 | 1) int n, t, m, w[maxn]; vector<int> mp[maxn]; string op; int c
阅读全文
摘要:百度之星2021 初试1 https://acm.hdu.edu.cn/showproblem.php?pid=6998 const int maxn = 1e6 + 7; int n, t, m, k; int dp[maxn]; void solve() { cin >> t; while (t
阅读全文

浙公网安备 33010602011771号