头像

Cyan

四川成都

深度强化学习炼丹师

ICPC2020-济南站

ICPC2020-济南站

2021-11-13 · 94次阅读 · 原创 · 数据结构与算法

C-Stone Game

#include<bits/stdc++.h> using namespace std; int main() { int a1, a2, a3, m, ans = 0; cin >> a1 >> a2 >> a3; m = min(a1, a2); ans += m * 2; a1 -= m; a2 -= m; if (a1 > 0) { ans += a1 / 3 * 3; if (a1 % 3 == 2) { ans += 1; } } else { ans += a2 / 3 * 6; if (a2 % 3 == 2) { ans += 4; } } cout << ans << endl; return 0; }

D-Fight against involution

#include<bits/stdc++.h> #define x first #define y second using namespace std; const int N = 1e5 + 5; long long s; int n; struct P { int lmax; int cnt; }; map<int, P> p; int main() { cin >> n; for (int i = 1, a, b; i <= n; i++) { scanf("%d%d", &a, &b); if (p.count(b) == 0) p[b] = {a, 1}; else p[b].cnt++, p[b].lmax = max(p[b].lmax, a); } int pre = 0; for (auto &ps:p) { pre = max(ps.y.lmax, pre); s += pre * ps.y.cnt; } cout << s << endl; return 0; }

G-Xor Transformation

#include<bits/stdc++.h> using namespace std; typedef long long LL; LL y, x; int main() { cin >> x >> y; LL XOR = x ^y; if (XOR < x) { printf("1\n%lld\n", XOR); return 0; } int k = 63; while (k >= 0 && !(XOR >> k & 1)) k--; LL maxv = 1ll << k; printf("2\n%lld %lld\n", XOR - maxv, maxv); return 0; }

M-Cook Pancakes!

#include<bits/stdc++.h> using namespace std; int n, k; int main() { cin >> n >> k; if (n <= k) { cout << 2 << endl; return 0; } cout << (n * 2 + k - 1) / k << endl; return 0; }

标题: ICPC2020-济南站
链接: https://www.fightingok.cn/detail/141
更新: 2022-09-18 22:42:24
版权: 本文采用 CC BY-NC-SA 3.0 CN 协议进行许可