目录 Codeforces 1000 A.Codehorses T-shirts B.Light It Up C.Covered Points Count(差分) D.Yet Another Problem On a Subsequence(DP) E.We Need More Bosses(圆方树) \(Description\) \(Solution\) F.One Occurrence(线段树) \(Description\) \(Solution\) G.Two-Paths(树形DP)…
目录 Codeforces 1009 A.Game Shopping B.Minimum Ternary String C.Annoying Present D.Relatively Prime Graph E.Intercity Travelling(递推) \(Description\) \(Solution\) F.Dominant Indices(启发式合并) G.Allowed Letters(Hall定理 位运算) \(Description\) \(Solution\) Codef…
目录 Codeforces 990 A.Commentary Boxes B.Micro-World C.Bracket Sequences Concatenation Problem D.Graph And Its Complement(思路 构造) E.Post Lamps(贪心) F.Flow Control(思路) G.GCD Counting(思路) Codeforces 990 比赛链接 真特么菜啊 后一个多小时无所事事.. 要多做CF的题啊,也许没有那么难但是就是容易想不到,代码也…
Educational Codeforces Round 84 (Div. 2) 读题读题读题+脑筋急转弯 = =. A. Sum of Odd Integers 奇奇为奇,奇偶为偶,所以n,k奇偶性要相同. 由求和公式得k个不同奇数组成的最小数为k2,所以n≥k2. #include <bits/stdc++.h> using namespace std; void solve(){ int n,k; cin>>n>>k; if((n-k)%2==0&&…
Bryce1010模板 http://codeforces.com/contest/1000/problem/E 题意: 给一个无向图,求图的最长直径. 思路:对无向图缩点以后,求图的最长直径 #include<bits/stdc++.h> #define ll long long using namespace std; const int maxn=600010; int From[maxn],Laxt[maxn],To[maxn<<2],Next[maxn<<2]…
Bryce1010模板 http://codeforces.com/problemset/problem/1000/C 题意:问你从[l,r]区间的被多少条线覆盖,列出所有答案. 思路:类似括号匹配的做法 #include <bits/stdc++.h> using namespace std; #define ll long long const ll MAXN=2e5+10; struct Node { ll num; ll dir;//0左1右 //ll cnt; }node[MAXN*…
Bryce1010模板 http://codeforces.com/problemset/problem/1000/B 思路:先用两个数组sumon[]和sumoff[]将亮着的灯和灭的灯累计一下. 然后从左到右扫描插入一个开关,取得到的最大值. #include<bits/stdc++.h> using namespace std; #define ll long long const int MAXN=1e5+10; ll sumon[MAXN]; ll sumoff[MAXN]; ll…
Bryce1010模板 http://codeforces.com/problemset/problem/1000/A 题意: 问你将一种类型的衣服转换成另一种的最小次数. #include<bits/stdc++.h> using namespace std; #define ll long long ll a[5][5],b[5][5]; int main(){ ll n; cin>>n; string s; for(ll i=0;i<n;i++) { cin>&g…
A - Codehorses T-shirts 思路:有相同抵消,没有相同的对答案+1 #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define pii pair<int, int> using namespace std; ; ; const int inf = 0x3f3f3f3f; const LL INF = 0x3…
这个题是dp, dp[i]代表以i开始的符合要求的字符串数 j是我们列举出的i之后一个字符串的开始地址,这里的C是组合数 dp[i] += C(j - i - 1, A[i]] )* dp[j]; #include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include &…