![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
codeforces
文章平均质量分 52
LZVSDY
不定期长蘑菇,疯子在左死宅在右
展开
-
Codeforces Round #794 (Div. 2) D. Linguistics
D. Linguistics思路暴力模拟,这题竟然 200020002000 分#include <bits/stdc++.h>using namespace std;#define PB push_backtypedef vector<int> VI;int a, b, c, d;VI res, ab, ba;void work(int num, int f) { if (num & 1) { res.PB(num); }原创 2022-05-30 10:46:21 · 252 阅读 · 0 评论 -
Codeforces Round #792 (Div. 1 + Div. 2) A ~ E
有空就写思路A - Digit Minimization#include <bits/stdc++.h>using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t -- ) { int n; cin >> n; int mn = 10原创 2022-05-21 22:03:31 · 133 阅读 · 0 评论 -
Codeforces Round #791 (Div. 2) D. Toss a Coin to Your Graph...
D. Toss a Coin to Your Graph…二分,dfs, toposort, dp#include <bits/stdc++.h>using namespace std;#define PB push_backtypedef long long LL;typedef vector<int> VI;const int N = 2e5 + 10;VI edg[N];int a[N], b[N];int in[N], dp[N];int n, m;L原创 2022-05-15 16:02:21 · 303 阅读 · 3 评论 -
Educational Codeforces Round 128 (Rated for Div. 2) E. Moving Chips
dp预处理:求 minminmin 所以初始化要 INFINFINF状态:dp[i][j]dp[i][j]dp[i][j] 中 iii 表示第 iii 位,jjj 取值 0,10,10,1 表示第 000 行,第 111 行转移方程:分四种情况,见代码#include <bits/stdc++.h>using namespace std;const int N = 2e5 + 10;int dp[N][2];int main() { ios::sync_with_std原创 2022-05-15 15:58:10 · 141 阅读 · 0 评论 -
Codeforces Round #786 (Div. 3)
I AK div3思路有空就写哈哈哈哈A - Number Transformation#include <bits/stdc++.h>using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t -- ) { int a, b; cin >>原创 2022-05-03 20:13:26 · 269 阅读 · 0 评论 -
Codeforces Round #783 (Div. 2) A ~ D
有空就写题解A. Direction Change#include <bits/stdc++.h>using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t -- ) { int n, m; cin >> n >> m;原创 2022-04-20 21:33:36 · 390 阅读 · 0 评论 -
Codeforces Round #782 (Div. 2)
明天有空就写题解A. Red Versus Blue#include <bits/stdc++.h>using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t -- ) { int n, r, b; cin >> n >> r &g原创 2022-04-18 01:35:12 · 336 阅读 · 0 评论 -
Codeforces Round #774 (Div. 2) A-D
太菜了,连D都写不出来,补完题目写题解A. Square Counting思路#include <bits/stdc++.h>using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t -- ) { LL n, s; cin >> n >原创 2022-03-05 01:37:44 · 304 阅读 · 0 评论 -
Codeforces Round #773 (Div. 2) A~D
有空就写题解A. Hard Way思路签到特判,一条边平行于 y=0y = 0y=0 的直线,且第三个点在该边下方#include <bits/stdc++.h>using namespace std;int main() { int t; cin >> t; while (t -- ) { int x1, y1, x2, y2, x3, y3; cin >> x1 >> y1 >&g原创 2022-02-25 17:44:45 · 553 阅读 · 0 评论 -
Codeforces Round #772 (Div. 2) A - E
没写思路,等我补完E再说吧A. Min Or Sum思路签到#include <bits/stdc++.h>using namespace std;int num[40];int main() { int t; scanf("%d", &t); while (t -- ) { for (int i = 0; i < 30; i ++ ) num[i] = 0; int n; scanf("%d",原创 2022-02-21 18:57:27 · 218 阅读 · 8 评论 -
Codeforces Round #771 (Div. 2) A -E
A. Reverse#include <bits/stdc++.h>using namespace std;const int N = 5e3 + 10;int a[N], b[N];int main() { int t; scanf("%d", &t); while (t -- ) { int n; scanf("%d", &n); for (int i = 1; i <= n; i ++原创 2022-02-15 01:46:52 · 579 阅读 · 5 评论 -
Codeforces Global Round 19
A - Sorting Parts思路签到#include <bits/stdc++.h>using namespace std;const int N = 1e4 + 10;int a[N], b[N];int main() { int t; cin >> t; while (t -- ) { int n; cin >> n; for (int i = 1; i <= n; i ++ ) {原创 2022-02-13 06:10:24 · 660 阅读 · 3 评论 -
The 15th Jilin Provincial Collegiate Programming Contest
The 15th Jilin Provincial Collegiate Programming ContestA. Random Number Checker签到#include <bits/stdc++.h>using namespace std;int main() { int n; cin >> n; int odd = 0, even = 0; for (int i = 1; i <= n; i ++ ) {原创 2022-02-05 17:27:49 · 2011 阅读 · 0 评论 -
Codeforces Round #768 (Div. 2) E. Paint the Middle
E. Paint the Middle#include <bits/stdc++.h>using namespace std;#define FI first#define SE second#define MP make_pair#define PB push_backtypedef pair<int, int> PII;const int N = 2e5 + 10;PII pos[N];vector<PII> seg;vector<PII&原创 2022-02-04 03:12:28 · 774 阅读 · 1 评论 -
Codeforces Global Round 17
A. Anti Light’s Cell GuessingAC(思维)#include <bits/stdc++.h>using namespace std;int main() { int t; scanf("%d", &t); while (t -- ) { int n, m; scanf("%d%d", &n, &m); if (n == 1 && m != 1) cout <<原创 2021-11-26 16:20:03 · 325 阅读 · 0 评论 -
2013-2014 ACM-ICPC Pacific Northwest Regional Contest
Delta Quadrant思路大体来说就是考虑当去掉 kkk 个点后,所有路径之和加起来乘上 222 就是答案,因为要往返为什么会想到是树形 dpdpdp我们先看数据范围,本来如果是图论,那个 kkk 给的范围是在是很小,同时,这里存在一个最优方案,去除 kkk 个点后最短路,一开始思路可能会歪,但是我们想,这时间复杂度必然爆炸,那么我们再看看,就会想到树形 dpdpdp,时间复杂度也很合适树形 dpdpdp 的状态dp[i][j]dp[i][j]dp[i][j] 的意思是以 iii 点为根原创 2021-11-23 19:34:46 · 101 阅读 · 0 评论 -
2020 China Collegiate Programming Contest, Weihai Site(施工ing)
C. Rencontre思路总结补题#include <bits/stdc++.h>using namespace std;#define FI first#define SE second#define MP make_pair#define PB push_backtypedef pair<int, int> PII;typedef vector<int> VI;const int N = 2e5 + 10;int cnt[4], num原创 2021-11-12 21:24:35 · 508 阅读 · 0 评论 -
Codeforces Round #744 (Div. 3)
A. Casimir’s String Solitaire#include <bits/stdc++.h>using namespace std;int main(){ int n; cin >> n; while (n -- ) { string str; int a = 0, b = 0, c = 0; cin >> str; int len = str.size(); for (int i = 0; i < len; i ++原创 2021-09-29 17:16:54 · 75 阅读 · 0 评论 -
Codeforces Round #317 [AimFund Thanks-Round] (Div. 2)
D. Minimization时间复杂度 O(nlogn+k2)O(nlogn + k ^ 2)O(nlogn+k2)思路我们首先可以想到,最大的情况就是,比如 k==n/2k == n / 2k==n/2 ∑i=1n−k∣A[i]−A[i+k]∣=a[n]−a[1]\sum_{i=1}^{n - k} |A[i] - A[i + k]| = a[n] - a[1]i=1∑n−k∣A[i]−A[i+k]∣=a[n]−a[1]然后我们考虑,我们如何使目标最小,我们想到的就是连着的串就是最小的,那么原创 2021-09-28 16:58:24 · 82 阅读 · 0 评论 -
Educational Codeforces Round 13
D. Iterated Linear Function思路求 Anx+An−1B+An−2B+.....+AB+BA^{n} x + A ^ {n - 1} B + A ^ {n - 2} B +..... + AB + BAnx+An−1B+An−2B+.....+AB+BAC(number theory)#include <bits/stdc++.h>using namespace std;int main(){ LL a, b, n, x; cin >&g原创 2021-09-25 18:51:50 · 58 阅读 · 0 评论 -
Codeforces Round #321 (Div. 2)
D. Kefa and DishesAC(ez)#include <bits/stdc++.h>using namespace std;int x[5], y[5];int main(){ int are = 0, cnt = 0, mx = 0; for (int i = 1; i <= 3; i ++ ) { cin >> x[i] >> y[i]; are += x[i] * y[i]; mx = max(mx原创 2021-09-22 16:15:49 · 79 阅读 · 0 评论 -
Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)
C. Fountains思路三种选法,C+DC + DC+D / D+DD + DD+D / C+CC + CC+CC+DC + DC+D : 两者都要有D+DD + DD+D / C+CC + CC+C : 至少有两个mx[i]mx[i]mx[i] : 在 iii 前最大的 beautifulbeautifulbeautifulcccccc / dddddd : 存储 PIIPIIPII 类型的数据,按照 pricepriceprice 排序细节注释AC(sorting)#in原创 2021-09-04 12:01:12 · 89 阅读 · 0 评论 -
Codeforces Round #106 (Div. 2)
A. Business tripAC(ez)#include <bits/stdc++.h>using namespace std;int a[20];int main() { int k; cin >> k; for (int i = 1; i <= 12; i ++ ) cin >> a[i]; sort(a + 1, a + 13); int sum = 0; int cnt = 0; for (int i = 13; i >=原创 2021-08-18 13:56:38 · 90 阅读 · 0 评论 -
2018-2019 ACM-ICPC, NEERC, Southern Subregional Contest, Qualification Stage
I. HeistAC(ez)#include <bits/stdc++.h>using namespace std;const int N = 1e3 + 10;int a[N];int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i ++ ) scanf("%d", a + i); sort(a + 1, a+ 1 + n); LL ans = 0; int pre = a[1]; f原创 2021-08-18 13:43:50 · 113 阅读 · 0 评论 -
2016-2017 ACM-ICPC, NEERC, Central Subregional Contest.
LINKA. Fried Fish思路注意 n<=kn <= kn<=k 的时候答案是 222AC(ez)#include <bits/stdc++.h>using namespace std;int main(){ freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); int n, k; cin >> n >> k; if (n原创 2021-08-16 20:32:25 · 169 阅读 · 0 评论 -
Educational Codeforces Round 60 (Rated for Div. 2) 1117
C. Magic Ship思路二分答案,看是否能在 midmidmid 时间内走完全程,能走完就更新 ansansans,不能就接着二分,对于不可能有解的样例,是不可能有更新的就离谱,想到二分了,还是模拟做,离谱dx[i]dx[i]dx[i] 表示的就是在这个时间点上,我在 xxx 上走的距离,每次都要更新,同理 dy[i]dy[i]dy[i]AC(two point)#include <bits/stdc++.h>using namespace std;typedef lo原创 2021-08-11 17:30:43 · 55 阅读 · 0 评论 -
2021 Shandong Provincial Collegiate Programming Contest
B.Build Roads思路AC(kruskal)#include <bits/stdc++.h>using namespace std;#define PB push_backtypedef long long LL;typedef unsigned long long ULL;const int N = 2e5 + 10;int n, L, R, a[N], p[N] = {0};ULL seed;struct edge{ int u, v, w; bool原创 2021-08-10 10:42:17 · 502 阅读 · 0 评论 -
Educational Codeforces Round 56 (Rated for Div. 2) 1093
D. Beautiful Graph思路AC(dfs and similar + graphs)#include <bits/stdc++.h>using namespace std;#define PB push_backtypedef long long LL;typedef vector<int> VI;const int mod = 998244353;const int N = 3e5 + 10;VI edge[N];int num[N];in原创 2021-08-09 10:23:08 · 61 阅读 · 0 评论 -
2020 ICPC Shanghai Site
B. Mine Sweeper II思路AC(math)#include <bits/stdc++.h>using namespace std;#define FI first#define SE second#define MP make_pair#define PB push_back#define rep(i, a, b) for(int i=(a); i<(b); i++)#define per(i, a, b) for(int i=(b)-1; i>=(原创 2021-08-08 14:35:23 · 424 阅读 · 0 评论 -
ACM International Collegiate Programming Contest, Egyptian Collegiate Programming Contest (ECPC 2015
D. Frozen Rivers思路AC(SPFA + two point)#include <bits/stdc++.h>using namespace std;const LL INF = 0x3f3f3f3f3f3f3f;const int mod = 1e9 + 7;const int N = 1e5 + 10;int h[N], e[N], ne[N], idx;LL tmp[N], dist[N], w[N];bool leaf[N];void add(i原创 2021-08-06 17:25:40 · 364 阅读 · 0 评论 -
Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
B. Weakened Common Divisor思路AC(math-gcd)#include <bits/stdc++.h>using namespace std;typedef long long LL;LL gcd(LL i, LL j) { return j ? gcd(j, i % j) : i;}LL out(LL n) { for (LL i = 2; i * i <= n; i ++ ) { if (n % i == 0) return i;原创 2021-08-06 17:19:53 · 53 阅读 · 0 评论 -
The 14th Jilin Provincial Collegiate Programming Contest
LINK签到题就不写了Problem C. String Game思路#include <bits/stdc++.h>using namespace std;const int mod = 1e9 + 7;const int N = 1e3 + 10;int dp[N];int main() { string a, b; while (cin >> a >> b) { memset(dp, 0, sizeof dp); int lena原创 2021-08-03 20:36:39 · 371 阅读 · 0 评论 -
The 2021 Sichuan Provincial Collegiate Programming Contest
L. Spicy Restaurant参考博客时间复杂度O(100∗(n+m))O(100 * (n + m) )O(100∗(n+m))思路w[i]<100w[i] < 100w[i]<100提示一开始我的思路是在考虑要不要就直接每个点 bfsbfsbfs,算了一下复杂度是 O(100n2)O(100n ^ 2)O(100n2),显然不对,所以就否定了该想法那么考虑多源 bfsbfsbfs ,时间复杂度就可以降低到 O(100(n+m))O(100(n + m))O(10原创 2021-08-02 20:00:51 · 379 阅读 · 0 评论 -
Codeforces Global Round 14
C. Phoenix and Towers思路显然,这个 towertowertower 一定成立.1.我们可以这样子想,把 nnn 个 blocksblocksblocks 平均分成 mmm 个,如果整除,皆大欢喜,肯定有一种可以使他们的差小于 xxx,如果不能整除,没有关系,我们仍然可以把他看成是先分成 mmm 个数量一样的 towertowertower 然后再加上余数,这样子,仍然可以.2.我们还可以这样子想,内一次都是给 highthighthight 最小的 towertowertow原创 2021-07-29 16:36:55 · 44 阅读 · 0 评论 -
Codeforces Global Round 15 1552
C. Maximize the IntersectionsAC(mysql)#include <bits/stdc++.h>using namespace std;#define FI first#define SE second#define MP make_pair#define PB push_backtypedef pair<int, int> PII;typedef vector<int> VI;const int N = 5e4 + 10;原创 2021-07-27 19:40:20 · 63 阅读 · 0 评论 -
Codeforces Round #729 (Div. 2)1542
C. Strange Function参考题解关于 gcdgcdgcd 和 lcmlcmlcm思路f(x)=if(x) = if(x)=i 的意义,就是他可以被之前的数整除,也就是求最小公倍数gcdgcdgcd 和 lcmlcmlcm容斥原理AC(math)#include <bits/stdc++.h>using namespace std;typedef long long LL;LL gcd(LL a, LL b) { if (b == 0) return a;原创 2021-07-27 17:34:46 · 61 阅读 · 0 评论 -
Harbour.Space Scholarship Contest 2021-2022 (open for everyone, rated, Div. 1 + Div. 2) 1553
D.Backspace思路对于前面的字符我们可以不管,只要输入我们就 backspacebackspacebackspace ,所以现在我们只考虑 jjj 能不能到 000, jjj 到 000 就弹出对于为什么我们 i−=2i -= 2i−=21.对于开始识别 ttt 开始,我们每个字符都被 backspacebackspacebackspace 代替,所以相当于每次删去两个字符,如果 ttt 被截断和 ttt 后面缀着东西,都是只能删去 222 个字符,也就是 i−=2i -= 2i−=2原创 2021-07-23 20:57:24 · 55 阅读 · 0 评论 -
Good Bye 2020 1466
C. Canine poetry思路回文串破坏,如何最小破坏,就是把 length==2length == 2length==2 和 length==3length == 3length==3 的回文串破坏AC(string)#include <bits/stdc++.h>using namespace std;int main() { int t; cin >> t; while (t -- ) { string str; cin >> str原创 2021-07-21 16:38:01 · 57 阅读 · 0 评论 -
Codeforces Round #561 (Div. 2) 1166
D. Cute Sequences思路这个题解不错,懒得写题解了细节见注释注释0:记录每一个 rrr 的值注释1:为什么此处是 a+1a + 1a+1 不是 aaa ,因为 rrr 的范围是 111 ~ mmm,所以为了防止 注释2 处出现 r[i]==0r[i] == 0r[i]==0 的情况,当我们把范围卡在 111 ~ mmm 的范围,我们就可以随便了注释2:从系数最大的 rrr 开始找,但是不可以超过 m−1m - 1m−1注释3:当我们找到了不满足他的情况就是我们找到的 nnn原创 2021-07-21 15:58:13 · 95 阅读 · 0 评论 -
Educational Codeforces Round 110 (Rated for Div. 2) 1535
C. Unstable String第一道写出来的DP,刚学DPAC(string dp)#include <bits/stdc++.h>using namespace std;typedef long long LL;const int N = 2e5 + 10;int f[N][2];int main() { int t; cin >> t; while (t -- ) { string str; cin >> str; int le原创 2021-07-20 17:23:15 · 60 阅读 · 0 评论