板刷atcoder vp

AtCoder Beginner Contest 322

AtCoder Beginner Contest 322 推荐视频:AtCoder Beginner Contest 322 A 至 F 題讲解 by dreamoon A. First ABC 2 解题思路: 遍历寻找连续的\(ABC\). 时间复杂度:\(O(n)\). 代码: #include ......
Beginner AtCoder Contest 322

板刷2023

CF1822 G1. Magic Triples (Easy Version) \(1 \leq a_i \leq 10^6\) 题解 显然关键在于\(j\),我们不妨枚举\(j\),显然\(a[i]\)是\(a[j]\)的约数 对于每个\(a[j]\)来说,枚举其约数,然后即可求出倍数\(b\), ......
板刷 2023

AtCoder Grand Contest 057 E RowCol/ColRow Sort

洛谷传送门 AtCoder 传送门 首先考虑一个经典的套路:转 \(01\)。具体而言,我们考虑若值域是 \([0, 1]\) 怎么做。 发现可以很容易地判定一个 \(A\) 是否合法。设矩阵第 \(i\) 行的和为 \(r_i\),第 \(j\) 列的和为 \(c_j\),那么合法当且仅当 \(A ......
AtCoder Contest ColRow RowCol Grand

板刷2023.10.04

CF1878 F.Vasilije Loves Number Theory 题解:约数个数 + 取模性质 对\(n\)质因子分解得到,\(n =p_1^{\alpha_1}p_2^{\alpha_2}...p_k^{\alpha_k}\) 那么显然\(d(n) = (\alpha_1 + 1)\ti ......
板刷 2023 10 04

AtCoder Grand Contest 036 F Square Constraints

洛谷传送门 AtCoder 传送门 本质是 \(p_i \in [l_i, r_i]\) 的计数问题。 当 \(1 \le i \le n\) 时,\(l_i\) 才可能不等于 \(1\)。考虑容斥,设钦定 \(m\) 个不满足条件(上界为 \(l_i - 1\)),其余任意(上界为 \(r_i\) ......
Constraints AtCoder Contest Square Grand

AtCoder Beginner Contest 288 Ex A Nameless Counting Problem

洛谷传送门 AtCoder 传送门 考虑到规定单调不降比较难搞。先设 \(g_t\) 为长度为 \(t\) 的满足条件的序列个数(可重且有顺序)。求这个可以设个 dp,\(f_{d, i}\) 表示考虑到从高到低第 \(d\) 位,当前 \(t\) 个数中有 \(i\) 个仍然顶上界,并且之前的位都 ......
Beginner Counting Nameless AtCoder Contest

Atcoder abl c

传送门 题目描述 有n个城市,m条双向路的图,问你最少添加几条路使得任意两个城市可以两两到达? 样例 样例输入 3 1 1 2 样例输出: 1 题目解析 这是个双向路的图,我们可以把它当成一个非连通图。在各个点之间有连线,要求我们算出如何能将整个图的各个部分连接起来。那么,我们只要算出这个非连通图由 ......
Atcoder abl

AtCoder——第一题

AtCoder Beginner Contest 322 F Vacation Query 题目大意 处理01字符串,给定Q次询问,询问区间内最长连续1的字符个数 题目理解 使用线段树维护区间 需要使用懒标记下传修改信号 线段树要维护7个信息(区间的最长连续1的个数、区间左端点开始连续1的个数、区间 ......
AtCoder

AtCoder Grand Contest 056 D Subset Sum Game

洛谷传送门 AtCoder 传送门 考虑若 \(n\) 是奇数怎么做。枚举 Alice 第一次选的数 \(a_i\),然后考虑把剩下的数两两结成一个匹配,若 Bob 选了其中一个,Alice 就选另一个。容易发现排序后奇数位和它右边的偶数位匹配最优。那么设奇数位的和为 \(A\),偶数位的和为 \( ......
AtCoder Contest Subset Grand Game

AtCoder Beginner Contest 178 E

AtCoder Beginner Contest 178 E E - Dist Max 曼哈顿距离最大点对 \(ans = max(|x_i-x_j|+|y_i-y_j|)\) 考虑去绝对值,4种情况。sort一下取max即可。 #include <bits/stdc++.h> using name ......
Beginner AtCoder Contest 178

AtCoder Beginner Contest 322

A - First ABC 2 解题思路 签到 Code #include <bits/stdc++.h> using namespace std; typedef long long LL; void solve() { int n; cin >> n; string s; cin >> s; i ......
Beginner AtCoder Contest 322

[AtCoder] E - Packing Under Range Regulations

Key idea: For a given box and a list of balls that can be placed in this box, we should choose the ball with the smallest R. Proof: say we have box B ......
Regulations AtCoder Packing Under Range

AtCoder Beginner Contest 322

A - First ABC 2 (abc322 A) 题目大意 给定一个字符串,找到最先出现ABC的位置。 解题思路 直接查找判断即可。 神奇的代码 #include <bits/stdc++.h> using namespace std; using LL = long long; int mai ......
Beginner AtCoder Contest 322

加训日记 Day3——atcoder ABC321乐子场

Day3,9.23 ·打了场acwing周赛,第三题差点就想出来了,想歪到组合数上乱选了呜呜呜 ·ABC321场写的太抽象了,A题上来wa两次,B题少考虑情况乱wa ·C题更是重量级,想不出来正确做法直接暴力,结果打表最后少写了几个数,纯纯犯病场 ·最后加了36分没绷住 acwing周赛排名 atc ......
乐子 atcoder 日记 Day3 Day

AtCoder Regular Contest 123 F Insert Addition

洛谷传送门 AtCoder 传送门 用 \((x, y)\) 表示 \(Ax + By\),那么这个等价于 SB 树。 那么直接在 SB 树上二分,遍历一遍找到 \(n\) 个点就好了。可以采用类似线段树查询的方式。 于是现在还剩下一个子问题:给定 \(a, b\),求 \(ax + by \le ......
Addition AtCoder Regular Contest Insert

AtCoder Regular Contest 127 F ±AB

洛谷传送门 AtCoder 传送门 非常妙的题。 先直观感受一下,显然当 \(M\) 大到一定程度后,\([0, M]\) 的所有数都能被取到。考虑 \(V \gets V + Ax + By\),其中 \(V + Ax + By \in [0, M]\)。如果 \(x, y\) 都是正数显然可以取 ......
AtCoder Regular Contest 127 177

Atcoder ABC321 笔记

A - 321-like Checker \(\color{gray}{22}\) 直接模拟 void solve() { int n; cin >> n; int lst = -1; for(int i = n; i; i /= 10) { int u = i % 10; if(u <= lst) ......
Atcoder 笔记 ABC 321

AtCoder Regular Contest 102

C - Triangular Relationship 枚举 \(a\bmod k\) 的值,\(b\bmod k,c\bmod k\) 的值也就确定了,算下贡献就好了。 #include<iostream> #include<cstdio> using namespace std; int n,k ......
AtCoder Regular Contest 102

AtCoder Regular Contest 103

C - //// 如果奇数和偶数出现的颜色的最大值相同一边取最大值和一边取次大值,否则两边都选最大值即可。 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=100005; ......
AtCoder Regular Contest 103

AtCoder Grand Contest 028

A - Two Abbreviations 答案要么就是 \(\operatorname{lcm}(n,m)\) 要么就是 \(-1\)。判断下 \(\operatorname{lcm}(n,m)\) 是否合法就是了。 #include<iostream> #include<cstdio> usin ......
AtCoder Contest Grand 028

AtCoder Grand Contest 027

A - Candy Distribution Again 从小到大贪心,可以发现一定是满足一个前缀,暴力判断就行了。 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=10 ......
AtCoder Contest Grand 027

AtCoder Grand Contest 026

A - Colorful Slimes 2 可以发现,对于连续的一段长度为 \(m\) 的相同的字符,我们可以花费 \(\lfloor \frac{m}{2}\rfloor\) 的代价将它改为符合要求的。 #include<iostream> #include<cstdio> using names ......
AtCoder Contest Grand 026

AtCoder Grand Contest 025

A - Digits Sum 按题意模拟即可。 #include<iostream> #include<cstdio> using namespace std; const int INF=1061109567; int n; int calc(int x) { int res=0; while(x ......
AtCoder Contest Grand 025

AtCoder Grand Contest 024

A - Fairness 每次操作后 \(a_i-b_i=b_{i-1}-a_{i-1}\),对 \(k\) 的奇偶性讨论一下即可。 #include<iostream> #include<cstdio> using namespace std; int a,b,c; long long k; in ......
AtCoder Contest Grand 024

AtCoder Grand Contest 023

A - Zero-Sum Ranges 令 \(s_n=\sum\limits_{i=1}^n a_i\),相当于找满足 \(l\le r,s_r-s_{l-1}\) 的点对 \((l,r)\) 的个数,直接搞就完事了。 #include<iostream> #include<cstdio> #in ......
AtCoder Contest Grand 023

AtCoder Grand Contest 022

A - Diverse Word 如果至少有一个字符没有出现过,只要在原字符串后面加入一个没有出现过的字符中最小的那个字符就好了。 如果所有字符都出现过,找到一个尽量靠后的位置 \(i\in [1,n)\),使得 \(s_i\lt s_{i+1}\),最优字符串将 \(s_i\) 换成 \([i+1 ......
AtCoder Contest Grand 022

AtCoder Grand Contest 021

A - Digit Sum 2 要么是 \(n\) 要么是 \(n\) 的第一位后面加上若干个 \(9\)。 #include<iostream> #include<cstdio> #include<cmath> using namespace std; long long n; int calc( ......
AtCoder Contest Grand 021

AtCoder Grand Contest 041

A - Table Tennis Training 如果 \(n\) 为偶数,一个 \(+1\) 一个 \(-1\) 即可。 如果 \(n\) 为奇数,那么肯定有一个先到了 \(1\) 或 \(n\),然后再 \(+1,-1\),取个较小值即可。 代码: #include<iostream> #in ......
AtCoder Contest Grand 041

AtCoder Grand Contest 040

A - >< 将所有的连续段缩起来,如果这个区间为 <,则左端点为 \(0\),依次递增;如果这个区间为 >,则右端点为 \(0\),分界点取个左右的 \(\max\) 就好了。 #include<iostream> #include<cstdio> #include<cstring> using ......
AtCoder Contest Grand 040

AtCoder Grand Contest 039

A - Connection and Disconnection 对于连续的一段连续的长度为 \(L\) 的段,至少需要 \(\frac{L}{2}\) 次操作。判下头尾相等的情况,实现时注意细节即可。 #include<iostream> #include<cstdio> #include<cst ......
AtCoder Contest Grand 039