分类: dp

8 篇文章

数据结构与算法课程项目题解
第1题代码丢了,论分类整理的重要性! 按回忆补一下第1题 #include <bits/stdc++.h> using namespace std; using ll=long long; ll n,ans=1e9; map<int,set<int>> mp; int main() { ios::sync_with_stdio(f…
Codeforces Round #851 (Div. 2)
E. Sum Over Zero 搞半天是数组开小了... #include<bits/stdc++.h> using namespace std; using ll=long long; int P; // assume -P <= x < 2P int norm(int x) { if (x < 0) { x += P;…
CCPC绵阳站解题报告
A. Ban or Pick, What's the Trick 考虑记忆化搜索,接下来便是如何设计状态了。 一个很简单的想法就是[A剩余的英雄][B剩余的英雄][A选择的英雄][B选择的英雄],但是$1\leqslant n \leqslant 10^5$,这种想法根本做不了。 然后很容易发现,英雄总数$n$减去B剩余的和选择的就是A禁用的英雄数…
冬日暖心赛 题解
差点翻车系列 A 断章取义 输出第L个到第R个字符串即可 #include <bits/stdc++.h> /* #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/hash_policy.hpp> */ using namespace std; …
CF1728D
考虑对于区间$[l,r]$, Bob是否可以达成平手。 如果Alice取$l$,Bob取$r$并且有$s[l]=s[r]$,那么区间就转移到了$[l+1,r-1]$上。相反的,如果Alice取$r$,那么Bob可以取$l$,也是同上的。 如果Alice取$l$,Bob取$l+1$并且有$s[l]=s[l+1]$,那么区间就转移到$[l+2,r]$上…
Codeforces Round #787 (Div. 3)解题报告
第一次变蓝了 Codeforces A. Food for Animals 判断$max(0ll,x-a)+max(0ll,y-b)$与$c$即可 B. Make It Increasing 从后往前模拟操作即可 C. Detective Task 容易推出答案是第一个0的位置减去第一个1的位置加一 注意一些特殊情况 D. Vertical Pat…
Codeforces Round #786 (Div. 3)解题报告
读假题,写假题,人麻了 A. Number Transformation 根据题意可以很简单的发现,如果y不能被x整除就输出0 0,否则输出1 $\frac{y}{x}$即可 B. Dictionary 手推一下即有:索引为(s[0]-'a')*25-(s[1]>s[0])+s[1]-'a' C. Infinite Replacement 根…
dp菜?
C. Palindrome Basis #include <algorithm> #include <bitset> #include <map> #include <vector> #include <string> #include <iostream> #include …