Codeforces Round 1036 A-F1 [250706]
2124A - Deranged Deletions m=2m=2m=2 的降序序列总是 derangement 的。 如果一个序列存在 i<ji<ji<j 且 ai>aja_{i}>a_{j}ai>aj,即存在 m=2m=2m=2 的降序子序列,则保留这两个元素,derangement。 否则,这个序列单调不降,其任意一个子序列也单调不降,不存在 derangement 的子序列。 复杂度 O(n2)\mathcal{O}(n^{2})O(n2),也可以做到 O(n)\mathcal{O}(n)O(n)。 123456789101112131415161718192021auto solve = [&] { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { for...
Codeforces Round 1035 A-D
2119A - Add or XOR 12345678910111213141516171819202122auto solve = [&] { int a, b, x, y; cin >> a >> b >> x >> y; if (a == b) { cout << 0 << endl; } else if (b == a - 1 && (a & 1)) { cout << y << endl; } else if (b < a) { cout << -1 << endl; } else { int res = 0; for (int i = a; i < b; i++) { if (i & 1) { res += x; } else { res +=...
English
.post-content { font-size: 120%; font-weight: 500; line-height: 3; } Jul.4 廣受贊譽 be widely acclaimed 贏得國際贊譽 win international acclaim 漁船 a fishing vessel 兇惡 / 兇殘的野獸 / 戰爭 a savage beast/war 激烈抨擊反對者 savage an opponent 朝他扔杯子 fling a cup at him 阻礙發展和進步 block development and progress 公寓大樓 a block of flats 團購 block bookings (block: 一批) 宜人的環境 a hospitable environment 好客的人 a hospitable person 培訓課 a training session 現在開庭 Court is now in...
Codeforces Round 1028 Div.1ABD / Div.2CDF
2115A / 2116C - Gellyfish and Flaming Peony 题意:给定一个包含 nnn 个正整数的数组 aaa。任意次操作:选择两个索引 iii 和 jjj,然后将 aia_iai 的值更新为 gcd(ai,aj)\gcd(a_i, a_j)gcd(ai,aj)。求出让数组中所有元素都相等所需的最少操作次数。 所有元素最终必然会相等,且等于整个初始数组的 GCD。问题的核心就变成了如何求得最小的 GCD。 方法一 :看到 5000 考虑 O(n2)\mathcal O(n^{2})O(n2) 的 DP。设 dpi,xdp_{i,x}dpi,x 表示前 iii 个数中至少需要选出几个数才能组合出 GCD 等于 xxx。复杂度 O(nVlogV)\mathcal O(nV\log...
The 3rd Universal Cup. Stage 1: St. Petersburg
The 3rd Universal Cup. Stage 1: St. Petersburg
Codeforces Round 1025 (Div. 2) CD
2109C - Hacking Numbers 像是游戏书的思维题 大方向是,用最少步骤得到一个确定的数 yyy,加上 n−yn-yn−y 得到答案。 C1:由于初始 xxx 范围巨大,先用 digit 操作是比较好的。发现两次 digit 操作的结果 x⩽16x \leqslant 16x⩽16,再按二进制拆分,四次就能得到 x=1x=1x=1。总计 6+1=76 + 1 = 76+1=7 次。 12345678910111213141516171819int n;cin >> n;int x;cout << "digit" << endl;cin >> x;cout << "digit" << endl;cin >> x;cout << "add " << -8 << endl;cin >> x;cout << "add " <<...
2025 CCPC 北京市赛暨小米杯全国邀请赛 比赛记录 + 个人题解
The 2024 ICPC Asia Nanjing Regional Contest (The 3rd Universal Cup. Stage 16: Nanjing)
Codeforces Round 1024 (Div. 1)
A - Mex in the Grid 由于不含 0 的网格的 MEX 都是 0,希望更多的网格包括 0,所以 0 放在正中间。数越小就要越靠近中心(严格证明可以看看官方题解),可以构造 12349 8 7 6 10 1 0 5 11 2 3 4 12 13 14 15 1234567891011121314151617181920212223242526272829303132333435363738394041#include <bits/stdc++.h>using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); int t; cin >> t; while (t--) { int n; cin >> n; vector a(n, vector<int>(n)); int x = (n + 1) / 2 - 1; int y = (n + 1) /...
〔主机註記〕第 66 周主机註記 (May.12 - May.18)
第 66 周主机註記 月曜日 (May.12) 火曜日 (May.13) 水曜日 (May.14) 木曜日 (May.15) 金曜日 (May.16) 土曜日 (May.17) 日曜日 (May.18)