atcoder contest grand 037

AtCoder Grand Contest 033

A - Darker and Darker 从 # 向外广搜即可。 #include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; const int N=1005; const i ......
AtCoder Contest Grand 033

AtCoder Grand Contest 032

A - Limited Insertion 考虑从后往前做,插数变成了删数。可以发现,我们可以删去的只有 \(a_i=i\) 的数,如果有多个肯定删最后面的是最优的,因为这样影响到的数最少。每次扫一遍找出删什么数即可。 #include<iostream> #include<cstdio> usin ......
AtCoder Contest Grand 032

AtCoder Grand Contest 030

A - Poisonous Cookies 解毒的饼干肯定所有都吃,剩下的算一下最多能吃多少毒饼干就好了。 #include<iostream> #include<cstdio> using namespace std; int A,B,C; int main() { scanf("%d%d%d", ......
AtCoder Contest Grand 030

AtCoder Grand Contest 029

A - Irreversible operation 对于某个 W 的位置,它的贡献即为前面 B 的个数,直接搞就完事了。 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N=2 ......
AtCoder Contest Grand 029

AtCoder Grand Contest 048

A - atcoder < S 枚举操作完的串 \(s\) 和 atcoder 相同的前缀长度,算出前面的前缀相同的代价加上当前这位大于 atcoder 中对应的那一位的代价即为达到当前状态的代价,取个最小值即可。 #include<iostream> #include<cstdio> #inclu ......
AtCoder Contest Grand 048

AtCoder Grand Contest 047

A - Integer Product 考虑将原来的数全部化为整数,乘上 \(10^9\),那么问题就变成了是否有两个数的乘积是 \(10^{18}\) 的倍数。考虑如果是 \(10^{18}\) 的倍数的话必然是 \(2^{18}\) 和 \(5^{18}\) 的倍数,那么分解出每个数的 \(2, ......
AtCoder Contest Grand 047

AtCoder Grand Contest 046

A - Takahashikun, The Strider 问题就是要你求 \(ax\equiv 0 \pmod{360}\) 中 \(a\) 的最小值。 答案就是 \(a=\frac{360}{\gcd(x,360)}\)。 代码: #include<iostream> #include<cstd ......
AtCoder Contest Grand 046

AtCoder Grand Contest 045

A - Xor Battle 可以发现,从后往前扫,遇到一个 \(1\) 找后面是否有若干个 \(0\) 的位置的 \(a_i\) 与当前位置的异或和相等,用线性基维护一下就好了。 代码: #include<iostream> #include<cstdio> #include<cstring> u ......
AtCoder Contest Grand 045

AtCoder Grand Contest 044

A - Pay to Win 不妨将操作倒过来考虑,问题就变成了每次除以 \(2,3,5\) 或者 \(+1,-1\),令 \(f_n\) 表示将 \(n\) 变成 \(0\) 的最小花费,然后记忆化搜索即可,可以证明复杂度是对的。 代码: #include<iostream> #include<c ......
AtCoder Contest Grand 044

AtCoder Grand Contest 043

A - Range Flip Find Route 可以发现,一条路径的最小操作数等于路径上有多少 # 的块,令 \(f_{i,j}\) 表示到 \((i,j)\) 的最小操作次数,直接 DP 就行了。 注意路径上一个 \(1\) 的块会被算两次,需要除以 \(2\)。 #include<iostr ......
AtCoder Contest Grand 043

[Leetcode Weekly Contest]364

链接:LeetCode [Leetcode]2864. 最大二进制奇数 给你一个 二进制 字符串 s ,其中至少包含一个 '1' 。 你必须按某种方式 重新排列 字符串中的位,使得到的二进制数字是可以由该组合生成的 最大二进制奇数 。 以字符串形式,表示并返回可以由给定组合生成的最大二进制奇数。 注 ......
Leetcode Contest Weekly 364

AtCoder Beginner Contest 318

AtCoder Beginner Contest 318 A - Full Moon (atcoder.jp) 以\(M\)为首项,\(P\)为公差,看\(1 \sim N\)里包含了多少项的个数 #include<bits/stdc++.h> using i64 = long long; usin ......
Beginner AtCoder Contest 318

AtCoder Regular Contest 165

Preface 这场前三题是上周四写的,今天课有点多本来想着把最近两场CF的博客先写下的 但后面发现还有CCLCC的杂谈没写,写完发现由于晚上要上课没时间了,只能先把这场先写一下 A - Sum equals LCM 设\(n=\prod_{i=1}^k p_i^{c_i}\),不难发现令\(A_1 ......
AtCoder Regular Contest 165

The 2023 ICPC Asia Regionals Online Contest (2) MDIELK

The 2023 ICPC Asia Regionals Online Contest (2) MDIELK M Dirty Work 题意:总共有\(n\)个问题,对于第\(i\)个问题需要\(a_i\)分钟。你可以随便选择一个没过的题去写,写完以后马上交,你有\(p_i\)的概率会错,错了不能跳 ......
Regionals Contest Online MDIELK 2023

题解 AtCoder Beginner Contest 268 A~H

RobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinC... ......
题解 Beginner AtCoder Contest 268

The 2023 ICPC Asia Regionals Online Contest (2)

Preface 这场打的有点捞说实话,两个小时出头的时候写完6个题就开始坐牢了 K题由于我习惯性地不写数论就扔给徐神了,徐神也是很有思路写了个看着就很对的东西,但不知道为什么过不去 赛后发现K其实是个很傻逼的题,类似的思路我最近补CF的时候还遇到过,但就是没细想 虽然当时下机的时候和祁神把A题的正解 ......
Regionals Contest Online 2023 ICPC

【题解】AtCoder-ABC321

AtCoder-ABC321A 321-like Checker 依题意判断。 提交记录:Submission - AtCoder AtCoder-ABC321B Cutoff 枚举 \(a_n\),依题意模拟即可。 提交记录:Submission - AtCoder AtCoder-ABC321C ......
题解 AtCoder-ABC AtCoder ABC 321

AtCoder Beginner Contest 321

A - 321-like Checker (abc321 A) 题目大意 给定一个数,问从高位到低位,数字是不是递减的。 解题思路 可以以字符串读入,然后依次判断即可。 神奇的代码 #include <bits/stdc++.h> using namespace std; using LL = lo ......
Beginner AtCoder Contest 321

AtCoder Grand Contest 046 E Permutation Cover

洛谷传送门 AtCoder 传送门 若 \(2\min\limits_{i = 1}^m a_i < \max\limits_{i = 1}^n a_i\) 就无解,因为根据排列的性质必然存在 \(yxxxy\) 或两端 \(xxyy\) 的情况,并且若这个条件不满足,就可以构造一组解。 考虑最小化 ......
Permutation AtCoder Contest Grand Cover

AtCoder Beginner Contest 318 ABCDE

AtCoder Beginner Contest 318 A - Full Moon 思路:等差数列求项数 // AC one more times // nndbk #include <bits/stdc++.h> using namespace std; typedef long long ll ......
Beginner AtCoder Contest ABCDE 318

AtCoder Beginner Contest 320 ABCDE

AtCoder Beginner Contest 320 A - Leyland Number 思路:直接快速幂 // AC one more times // nndbk #include <bits/stdc++.h> using namespace std; typedef long long ......
Beginner AtCoder Contest ABCDE 320

AtCoder Beginner Contest 253 E

AtCoder Beginner Contest 253 E - Distance Sequence 思路:前缀和优化DP 要求$ |a[i]-a[i+1]|>=k\( 定于\)dp[i][j]:\(前\)i\(个数以\)j\(结尾的合法序列数列 \) dp[i][j] += dp[i-1][1~( ......
Beginner AtCoder Contest 253

2021-2022 ICPC Northwestern European Regional Programming Contest (NWERC 2021)

A. Access Denied 先问若干次,问出长度,然后再一位一位的问即可。 #include <bits/stdc++.h> using namespace std; int input() { string s; getline(cin, s); if (s == "ACCESS GRANT ......

The 2021 China Collegiate Programming Contest (Harbin) JBEID

The 2021 China Collegiate Programming Contest (Harbin) JBEID J. Local Minimum 模拟 题意:一个数当且仅当它是当前列最小值同时也是当且行的最小值它才算入贡献。 思路:直接\(for\),预处理出每一行每一列的最小值,然后去\ ......
Programming Collegiate Contest Harbin China

Atcoder-Countings3

目录Atcoder-Countings3IntroAC01 [ABC266G] Yet Another RGB Sequence(2045)ProblemSolutionAC02 [ARC162E] Strange Constraints(2780)ProblemSolutionAC03 [ARC1 ......
Atcoder-Countings Countings Atcoder

AtCoder Beginner Contest 313 Ex Group Photo

洛谷传送门 AtCoder 传送门 考虑若重排好了 \(a\),如何判断可不可行。显然只用把 \(b\) 排序,把 \(\min(a_{i - 1}, a_i)\) 也排序(定义 \(a_0 = a_{n + 1} = +\infty\)),按顺序逐个判断是否大于即可。 这启示我们将 \(\min( ......
Beginner AtCoder Contest Group Photo

2019, XII Samara Regional Intercollegiate Programming Contest

\(Problem A. Rooms and Passages\) 倒着处理每个位置正数的最前部的位置。 如果是正数,显然答案为后一个位置的答案 \(+1\) 。 如果是负数且前面出现过相应的正数,答案要对这个区间长度 \(-1\) 的取 \(min\) 。 void solve(){ int n= ......

AtCoder Grand Contest 017

链接 C. Snuke and Spells 容易发现合法序列排序后一定是若干段值域连续的部分组成: 可以发现最小次数就是重叠/空出的部分大小。 每次修改只会对 \(O(1)\) 个点 \(±1\),直接维护即可。 #include<iostream> #include<cstdio> #inclu ......
AtCoder Contest Grand 017

The 2023 ICPC Asia Regionals Online Contest (1)

Preface 这场打的还行,因为学长们都没发挥好被我们队偷了,但感觉发挥的也一般 前期开题顺序有点问题导致罚时很高,不过中期写题还是很顺的基本都是一遍过 只不过在3h的时候过完F到达8题后就开始坐牢了,虽然这场有两个字符串但徐神把H想复杂了,B可以说前面的建SAM和反串的AC自动机都想到了,也转化 ......
Regionals Contest Online 2023 ICPC

AtCoder Grand Contest 023 E Inversions

洛谷传送门 AtCoder 传送门 首先将 \(a\) 从小到大排序,设 \(p_i\) 为排序后的 \(a_i\) 位于原序列第 \(p_i\) 个位置,\(x_i\) 为要填的排列的第 \(i\) 个数。 设 \(A = \prod\limits_{i = 1}^n (a_i - i + 1)\ ......
Inversions AtCoder Contest Grand 023