- 博客(59)
- 收藏
- 关注
原创 Codeforces Round #794 (Div. 2) D. Linguistics
D. Linguistics 思路 暴力模拟,这题竟然 200020002000 分 #include <bits/stdc++.h> using namespace std; #define PB push_back typedef 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
342
原创 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
236
原创 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_back typedef 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
441
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
225
原创 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
334
原创 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
466
原创 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
410
原创 The 16-th Beihang University Collegiate Programming
Link 有空就写题解 A #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int a[N], b[N]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i ++ ) cin >> a[i]; for (int i = 1; i <= m; i ++
2022-03-06 21:45:16
341
原创 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
408
原创 The 2021 Hangzhou Normal U Summer Trials
Link 每天补题就好忙了,没时间写思路QWQ,有时间就写思路 A. Aahaxiki’s journey I - set off 思路 dijkstradijkstradijkstra 算法,没啥说的 思路就是拆点,把机场和火车站拆开,建图 考虑: 起点机场 -> 终点机场 起点机场 -> 终点火车 起点火车 -> 终点机场 起点火车 -> 终点火车 特判 n=1n = 1n=1 的时候 两次 dijkstradijkstradijkstra 就够用 注意,这题会卡常数,必须快
2022-03-01 11:06:30
510
原创 2021 ECNU Campus Invitational Contest
Link 思路没写,有空就写思路 A. Abstract Algebra #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, c, d; cin >> a &
2022-02-27 12:55:55
332
原创 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
638
原创 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
346
8
原创 The 2021 Shanghai Collegiate Programming Contest A,B,C,D,E,G,H,J,K
The 2021 Shanghai Collegiate Programming Contest 没写完,今天困了,如果明天起来我还记得我就接着写 A. 小 A 的点面论 思路 垂直向量,高中数学,枚举就好,公式计算挺麻烦的 #include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d, e, f; cin >> a >> b >> c >> d
2022-02-21 00:30:37
875
原创 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
710
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
781
3
原创 The 15th Jilin Provincial Collegiate Programming Contest
The 15th Jilin Provincial Collegiate Programming Contest A. 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
2167
原创 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_back typedef pair<int, int> PII; const int N = 2e5 + 10; PII pos[N]; vector<PII> seg; vector<PII&
2022-02-04 03:12:28
918
1
原创 Codeforces Global Round 17
A. Anti Light’s Cell Guessing AC(思维) #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
439
原创 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
181
原创 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_back typedef pair<int, int> PII; typedef vector<int> VI; const int N = 2e5 + 10; int cnt[4], num
2021-11-12 21:24:35
642
原创 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
135
原创 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
161
原创 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+B AC(number theory) #include <bits/stdc++.h> using namespace std; int main(){ LL a, b, n, x; cin >&g
2021-09-25 18:51:50
128
原创 Codeforces Round #321 (Div. 2)
D. Kefa and Dishes AC(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
153
原创 Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)
C. Fountains 思路 三种选法,C+DC + DC+D / D+DD + DD+D / C+CC + CC+C C+DC + DC+D : 两者都要有 D+DD + DD+D / C+CC + CC+C : 至少有两个 mx[i]mx[i]mx[i] : 在 iii 前最大的 beautifulbeautifulbeautiful cccccc / dddddd : 存储 PIIPIIPII 类型的数据,按照 pricepriceprice 排序 细节注释 AC(sorting) #in
2021-09-04 12:01:12
178
原创 Codeforces Round #106 (Div. 2)
A. Business trip AC(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
180
原创 2018-2019 ACM-ICPC, NEERC, Southern Subregional Contest, Qualification Stage
I. Heist AC(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
192
原创 2016-2017 ACM-ICPC, NEERC, Central Subregional Contest.
LINK A. Fried Fish 思路 注意 n<=kn <= kn<=k 的时候答案是 222 AC(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
267
原创 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
126
原创 2021 Shandong Provincial Collegiate Programming Contest
B.Build Roads 思路 AC(kruskal) #include <bits/stdc++.h> using namespace std; #define PB push_back typedef 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
651
原创 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_back typedef 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
134
原创 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
550
原创 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
503
原创 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
119
原创 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
490
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅