Atcoder

2024/4/12 3:14:37

AtCoder Regular Contest 137 题解(A~C)

A-Coprime Pair 思路 我们知道两个质数之间并不会相隔太远&#xff0c;于是我们直接用暴力就可以通过这题。 先从大到小枚举答案&#xff0c;并且枚举所有可能的起点&#xff0c;当枚举到的两个值满足条件输出并结束程序即可。 代码 #include <bits/stdc.h> using n…

[AGC031F]Walk on Graph

Description 有一张n个点m条边的无向连通图G&#xff0c;每条边有长度ci&#xff0c;有一个人在上面走 有q组询问&#xff0c;每组询问给出si,ti,ri&#xff0c;表示问你是否存在一条从si出发到ti结束长度为ri%Mod的路径 注意这里的路径长度是∑ci*2^i n,m,q<50000,Mod<…

[AGC018F]Two Trees

Description 给出两棵有根树&#xff0c;需要给每个点确定点权&#xff0c;使得两棵树中每个子树的权值和的绝对值为1 n<100000 Solution 构造好题&#xff0c;本来打算讲杂题但是出到模拟赛就直接写了 设第一棵树为1~n&#xff0c;第二棵树为n1 ~ 2n 首先我们可以确定每…

atcoder agc001F Wide Swap

Description 给出一个长度为n的排列p&#xff0c;每次操作你可以交换任意两个满足|i-j|>k并且|pi-pj|1的pi和pj。 求任意次操作之后所得的最小字典序的排列。 n<5*1e5 Solution 感觉agc的题都是些很吼的思维结论题啊。。。以后要多做做 这个模型感觉会很难做&#…

KAJIMA CORPORATION CONTEST 2024(AtCoder Beginner Contest 340)ABCDEF 视频讲解

这场比较郁闷&#xff0c;C题短路&#xff0c;连续4次WA&#xff0c;导致罚时太多 A - Arithmetic Progression Problem Statement Print an arithmetic sequence with first term A A A, last term B B B, and common difference D D D. You are only given inputs for w…

AtCoder-5039 AB Substrings

See the original article https://dyingdown.github.io/2019/11/17/AtCoder-5039-AB-Substrings/ AB Substring Problem Statement Snuke has NNN strings. The i−thi-thi−th string is sis_isi​. Let us concatenate these strings into one string after arranging t…

AtCoder-4871 Lower

See the original article https://dyingdown.github.io/2019/11/17/AtCoder-4871-Lower/ Lower Problem Statement There are NNN squares arranged in a row from left to right. The height of the i−thi-thi−th square from the left is HiH_iHi​. You will land o…

AtCoder abc129

C Typical Stairs 斐波那契的变种&#xff0c;有障碍时填0 D Lamp 对每个点维护四个方向可以延伸的最长值 E - Sum Equals Xor 数位dp f ( p o s , x , c a p ) f(pos, x, cap) f(pos,x,cap) 表示在二进制表示下&#xff0c;当前搜索到pos位 因为当前位只有三种可能 (0,0) (1,…

Toyota Programming Contest 2024#3(AtCoder Beginner Contest 344)(A~C)

A - Spoiler 竖线里面的不要输出&#xff0c;竖线只有一对&#xff0c;且出现一次。 #include <bits/stdc.h> //#define int long long #define per(i,j,k) for(int (i)(j);(i)<(k);(i)) #define rep(i,j,k) for(int (i)(j);(i)>(k);--(i)) #define debug(a) cou…

Codeforces Round 935 (Div. 3)A~E

A. Setting up Camp 题目分析: 有三种人&#xff0c;内向、外向、综合&#xff0c;内向必须独自一个帐篷&#xff0c;外向必须3个人一个帐篷&#xff0c;综合介于1~3人一个帐篷&#xff0c;我们发现非法情况只会存在外向的人凑不成3个人一个帐篷的情况&#xff0c;因外向不够可…

AtCoder Regular Contest 174

A.A Multiply&#xff08;贪心&#xff09; 题意&#xff1a; 给你一个长度为 N N N 、 A ( A 1 , A 2 , … , A N ) A(A_1,A_2,\dots,A_N) A(A1​,A2​,…,AN​) 和整数 C C C 的整数序列。 在进行最多一次以下操作后&#xff0c;求 A A A 中元素的最大可能和&#xff…

Atcoder Beginner Contest 332 (A - F 题)

目录 [A - Online Shopping](https://atcoder.jp/contests/abc332/tasks/abc332_a)Problem StatementConstraintsInputOutputSample Input 1Sample Output 1Sample Input 2Sample Output 2Sample Input 3Sample Output 3 SolutionCode [B - Glass and Mu](https://atcoder.jp/c…

Atcoder Beginner Contest 330——A~F题

A - Counting Passes Description Problem Statement N N N people labeled 1 , 2 , … , N 1,2,\dots,N 1,2,…,N took an exam, and person i i i scored A i A_i Ai​ points. Only those who scored at least L L L points pass this exam. Determine how many peopl…

Codeforces Round 916 (Div. 3)A~E2

目录 A. Problemsolving Log 问题分析: B. Preparing for the Contest 问题分析: C. Quests 问题分析: D. Three Activities 题目分析&#xff1a; E1、E2. Game with Marbles (Hard Version) 题目分析&#xff1a; F. Programming Competition 待更... A. Problem…

AtCoder abc148

C题 求GCD D题 顺序遍历 E题 trailing zero只与5的个数有关&#xff0c;因此算一下5/25/125…的倍数 # -*- coding: utf-8 -*- # time : 2023/6/2 13:30 # file : atcoder.py # software : PyCharmimport bisect import copy import sys from itertools import perm…

ABC253F Operations on a Matrix

题意 给定一个n*m的方格&#xff0c;初始均为0&#xff0c;有以下三种操作&#xff1a; 1.给l-r行每个位置加x 2.给l列每个位置修改为x 3.询问x列y行的值 分析 我们考虑第q次询问的答案&#xff0c;是由上一次修改第y列的位置q&#xff0c;和q-q次之间修改x行的和组成的 …

(AtCoder Beginner Contest 341)(A - D)

比赛地址 : Tasks - Toyota Programming Contest 2024#2&#xff08;AtCoder Beginner Contest 341&#xff09; A . Print 341 模拟就好了 &#xff0c; 先放一个 1 , 然后放 n 个 01 ; #include<bits/stdc.h> #define IOS ios::sync_with_stdio(0);cin.tie(0);cout…

AtCoder ABC146

C题 可以证明 A N B d ( N ) ANBd(N) ANBd(N) 是单调递增&#xff0c;因此二分 # -*- coding: utf-8 -*- # time : 2023/6/2 13:30 # file : atcoder.py # software : PyCharmimport bisect import copy import sys from itertools import permutations from sorte…

AtCoder abc140

C - Maximal Value 遍历比较一下相邻的值 D - Face Produces Unhappiness 反向思维&#xff0c;考虑不开心的点 字符串可以规约成RR…RLL…LRR…RL…L这样相间的情况 每次操作只有把整段的R或者L反向&#xff0c;才能减少不开心的点 有几种不同的情况 RLRLR LRLR RLRL LRLRL 2.…

Educational Codeforces Round 160 (Rated for Div. 2) A~C

目录 A. Rating Increase 题目分析&#xff1a; B. Swap and Delete 题目分析: C. Game with Multiset 题目分析: A. Rating Increase 题目分析&#xff1a; 因为首部不为零&#xff0c;故我们从第二个字符开始遍历&#xff0c;如果遇到第一个不为‘0’的字符&#xff0…

AtCoder ABC132

陷入了“会做&#xff0c;但不完全会做”的状况 C 水题&#xff0c;排序找中间数两边的差值 D 组合数学 求把n个相同的球分到m个相同的盒子&#xff0c;1每个盒子至少一个球2每个盒子球不限的组合数 空挡插隔板法&#xff0c;高中数学 # -*- coding: utf-8 -*- # time : 2…

AtCoder Beginner Contest 297(A-E)

比赛地址: AtCoder Beginner Contest 297 - AtCoder A - Double Click 思路 : 直接模拟即可 代码 : #include<bits/stdc.h> #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define endl \nusing namespace std; typedef long long LL;inline vo…

AtCoder Beginner Contest 331

感觉和cf div3差不多。 A - Tomorrow 签到&#xff0c;D和M是一年有D月M天&#xff0c;输入ymd输出ym[d1]&#xff0c;如果d1>D了显然要m&#xff0c;模拟即可。 #include <bits/stdc.h> //#define int long long #define fr first #define se second #define endl …

Atcoder abc127

C 遍历&#xff0c;根据每个线段最左和最右不断“缩小”&#xff0c;最终得到答案 D 在原始牌和新牌中挑出N张最大&#xff0c;重新组成数组 排序后双指针 E x y分开计算 任取一对点 x 1 , x 2 x_1,x_2 x1​,x2​&#xff0c;记d为两个点的x差值&#xff0c;剩下可以随意取k-2个…

AtCoder abc130

F题提交了无数遍&#xff0c;最后发现是三分求解的写法错了 C - Rectangle Cutting 盲猜都在xy的中心点时可以无限分割&#xff0c;否则不能 D - Enough Array 前缀和二分求位置 E - Common Subsequence 公共子序列求有几种组合 设 d p [ i ] [ j ] dp[i][j] dp[i][j]代表s取到…

Codeforces Round 913 (Div. 3) A~E

目录 A. Rook 问题分析: B. YetnotherrokenKeoard 问题分析: C. Removal of Unattractive Pairs 问题分析: D. Jumping Through Segments 问题分析: E. Good Triples 问题分析: A. Rook 问题分析: 给一个棋子将其同行同列的位置输出 #include<bits/s…

[ARC 063 F]Snuke's Coloring 2

Description 给出一个wxh的网格图&#xff0c;和n个点&#xff0c;求一个周长最大的矩形&#xff0c;满足这个矩形内部没有点。注意矩形边界上不算在内部。 n<2*1e5 Solution 首先让我们来想一个分治做法。 分治了一条中线&#xff0c;我们想要求出跨过中线的答案。 那…

AtCoder-5165 Kleene Inversion

See the original article https://dyingdown.github.io/2019/11/22/AtCoder-5165-Kleene-Inversion/ Kleene Inversion Problem Statement We have a sequence of N integers AA0,A1,⋯,AN−1A~~ A_0,~A_1,~ \cdots,~A_{N−1}A A0​, A1​, ⋯, AN−1​. Let B be a sequ…

AtCoder-4873 ModSum

See the original article https://dyingdown.github.io/2019/11/17/AtCoder-4873-ModSum/ ModSum Problem Statement For an integer N, we will choose a permutation {P1,P2,⋯,PN}\{P_1,P_2,\cdots,P_N\}{P1​,P2​,⋯,PN​} of {1,2,⋯,N}\{1,2,\cdots,N\}{1,2,⋯,N}. …

Monoxer Programming Contest 2024(AtCoder Beginner Contest 345)(A~C)

A - Leftrightarrow 如果字符串最左边是<&#xff0c;最右边是>&#xff0c;中间都是&#xff0c;那么就输出Yes&#xff0c;否则No #include <bits/stdc.h> //#define int long long #define per(i,j,k) for(int (i)(j);(i)<(k);(i)) #define rep(i,j,k) for…

Atcoder abc141

C - Attack Survival 遍历 D - Powerful Discount Tickets 堆贪心&#xff0c;每次操作都在最大的那一个&#xff0c;然后重新插入 # -*- coding: utf-8 -*- # time : 2023/6/2 13:30 # author : yhdutongwoo.cn # desc : # file : atcoder.py # software : PyC…

AtCoder 5633 Counting of Trees

See the original article https://dyingdown.github.io/2019/11/21/AtCoder-5633-Counting-of-Trees/ Counting of Trees Problem Statement Given is an integer sequence D1,D2,⋯,DND_1, D_2, \cdots, D_ND1​,D2​,⋯,DN​ of N elements. Find the number, modulo 998…

AtCoder-4297 Monsters Battle Royale

See the original article https://dyingdown.github.io/2019/11/17/AtCoder-4297-Monsters-Battle-Royale/ Monsters Battle Royale Problem Statement There are N monsters, numbered 1,2,…,N. Initially, the health of Monster iii is AiA_iAi​. Below, a monster …

AtCoder Beginner Contest 318 G - Typical Path Problem 题解

G - Typical Path Problem 题目大意 给定一张 N N N 个点、 M M M 条边的简单无向图 G G G 和三个整数 A , B , C A,B,C A,B,C。 是否存在一条从顶点 A A A 到 C C C&#xff0c;且经过 B B B 的简单路径&#xff1f; 数据范围&#xff1a; 3 ≤ N ≤ 2 1 0 5 3\le …

AtCoder abc 136

C 从后向前贪心 D 寻找规律 推一下可以发现连续的RR…RLL…L可以作为一个独立的循环节 最后这个循环节内的数字集中在RL的交界处 再处理一下奇偶性就好 # -*- coding: utf-8 -*- # time : 2023/6/2 13:30 # author : yhdutongwoo.cn # desc : # file : atcoder.…

AtCoder Beginner Contest 329 题解A~F

A - Spread 输入字符串&#xff0c;字符之间加上空格输出 B - Next 输出数组当中第二大的数 C - Count xxx 统计每个字符出现过的最长长度&#xff0c;再累加即可 #include<bits/stdc.h> #pragma GCC optimize("Ofast") #define INF 0x3f3f3f3f #define I…

KAJIMA CORPORATION CONTEST 2024(AtCoder Beginner Contest 340)(A~D)

A - Arithmetic Progression 给你A,B,D&#xff0c;输出A&#xff0c;AD&#xff0c;A2*D&#xff0c;...到B为止&#xff0c;一个循环就可以解决。 #include <bits/stdc.h> //#define int long long #define per(i,j,k) for(int (i)(j);(i)<(k);(i)) #define rep(i…

Atcoder abc131

C 容斥原理 要注意同时能被CD整除的数应该是x%gcd(C,D) 0 D 排序后贪心 这个题的难度比400分要低 E 容易想到将1点放在中心&#xff0c;其他点像星型连接1点&#xff0c;是K的上限 然后要观察到每连接两个点将当前的k值减一&#xff0c;就容易构造 F xy坐标系拆开坐标建图&…

AtCoder Beginner Contest 333 A~E

目录 A - Three Threes B - Pentagon C - Repunit Trio D - Erase Leaves E - Takahashi Quest A - Three Threes 输入一个数n&#xff0c;输出n个n. B - Pentagon 给定一个正五边形&#xff0c;任意给两对顶点&#xff0c;问这两对顶点之间的距离是否相同&#xf…

AtCoder ABC150

C题 签到题。会python的permutations 或者C的next_permutation就能做。 D题 乍一看很简单&#xff0c;把所有元素折半求最小公倍数lcm&#xff0c;然后求lcm的奇数倍即可。但是有坑&#xff1a; 比如6 4这种情况&#xff0c;lcm6 但661 641.5&#xff0c;因此无法满足要求。原…