- 博客(1116)
- 收藏
- 关注
原创 Codeforces Round 1022 (Div. 2) 题解
B SUMdamental DecompositionC Neo’s EscapeD Needle in a NumstackE Spruce DisputeF Fallen Towers皮萨诺建造了由 nnn 座塔楼组成的 aaa 阵列,每座塔楼由 ai≥0a_i \ge 0ai≥0 块砖块组成。皮扎诺可以推倒一座塔,使接下来的 aia_iai 座塔增加 111 个。换句话说,他可以利用 aia_iai 元素,将接下来的 aia_iai 元素增加一个,然后将 aia_iai 设
2025-05-04 15:11:17
1142
原创 Codeforces Round 1019 (Div. 2) 题解
You are given an array of integers a1,a2,…,ana_1, a_2, \ldots, a_na1,a2,…,an. An array x1,x2,…,xmx_1, x_2, \ldots, x_mx1,x2,…,xm is beautiful if there exists an array y1,y2,…,ymy_1, y_2, \ldots, y_my1,y2,…,ym such that the elements of yyy are dist
2025-04-23 12:29:08
799
原创 Neowise Labs Contest 1 (Codeforces Round 1018, Div. 1 + Div. 2) 题解
BC Wonderful City给1个矩阵,第i行加1需要ci代价,第i列需要di代价,每行,每列只能加1次。问最小代价使矩阵不存在相邻元素相同。每行每列取不取只被上行影响。行列可分离考虑。D Wonderful LightbulbsYou are the proud owner of an infinitely large grid of lightbulbs, represented by a Cartesian coordinate system. Initially, all of th
2025-04-23 11:15:27
1061
原创 AtCoder Beginner Contest 401 题解
B UnauthorizedC K-bonacciD Logical FillingE Reachable SetF Add One Edge 3一个树上点的最远点是直径的两个点之一G Push Simultaneously二分,二分图匹配
2025-04-22 07:07:38
588
1
原创 April Fools Day Contest 2025
直接输出一行B Plinko给一个弹珠游戏找起始点,要求掉到底。输出-1,直接从场外掉C Would It Be Unrated?猜有多少testcase,只能靠穷举,但是只要有人过了。提交页面可以查看过了至少k的点的提交。D Where Am I?给一个位置求坐标需要使用google街景定位,右键可以确定坐标。虽然图片看起来在纽约,但实际是在拉斯维加斯E Pair Count给你一个质数 ppp , nnn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_na1
2025-04-02 11:58:03
939
原创 Japan Registry Services (JPRS) Programming Contest 2025#1 (AtCoder Beginner Contest 392) 题解
B - Who is Missing?C - BibD - DoublesE - Cables and ServersF - InsertG - Fine Triplets给NNN个两两不同的数SiS_iSi,问能凑出多少三元组,正好可以组成等差序列。1≤N,Si≤1061\le N,S_i \le 10^61≤N,Si≤106枚举中间那个数,另外两个数的和是确定的,上FFT。
2025-02-09 07:45:30
834
原创 Good Bye 2024: 2025 is NEAR 题解
A Tender Carpenter给一个数列分是否存在至少2种划分方式使得划分后每个子段中的数任取(可重复取)3个都能作为三角形的3条边长。#include<bits/stdc++.h> using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define ForkD(i,k,n) for(int i=n;i>=k;i-
2024-12-30 05:06:11
963
原创 ABC 385G(Counting Buildings-多项式)
求有多少个长度为 n 的排列 P,其从左往右的单调栈长度L§ 和从右往左的单调栈长度R§之差为 k。表示长度为i且差值为j的答案。
2024-12-27 05:48:02
1017
2
原创 AtCoder Beginner Contest 382 题解
A - Daily Cookie int n,k; cin>>n>>k; string p; cin>>p; int c=0; Rep(i,p.length()) c+=p[i]=='@'; cout<<n-c+min(k,c);B - Daily Cookie 2 int n,k; cin>>n>>k; string p; cin>>p; RepD(i,n-1) { if(p[i]=='@
2024-12-03 23:38:29
1028
原创 AtCoder Beginner Contest 380 题解
A - 123233#include<bits/stdc++.h> using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define ForkD(i,k,n) for(int i=n;i>=k;i--)#define Rep(i,n) for(int i=0;i<n;i++)#define ForD(i,n) f
2024-11-17 00:51:30
764
原创 Meta Hacker Cup 2024 Round 2 题解
Cottontail Climb (Part 1)暴力枚举Cottontail Climb (Part 2)暴力枚举Problem B: Four in a Burrow记忆化搜索Problem C: Bunny Hopscotch统计todo
2024-10-22 08:57:19
1166
原创 KEYENCE Programming Contest 2024(AtCoder Beginner Contest 374) 题解
Problem StatementKEYENCE has a culture of addressing everyone with the suffix “-san,” regardless of roles, age, or positions.You are given a string S consisting of lowercase English letters.If S ends with san, print Yes; otherwise, print No.B - Unvarnish
2024-10-06 10:02:51
1005
2
原创 AtCoder Beginner Contest 366 题解
B -B - Vertical WritingC - Balls and Bag QueryD - Cuboid Sum QueryE - Manhattan Multifocal EllipseF - Maximum CompositionG - XOR Neighbors给一个n个点m条边的无向连通图,给每个点分配点权([1,260][1,2^{60}][1,260]中的整数),要求对于所有度数非0的点,所有和它相邻的点(不包括自己)的点权xor和为0.高斯xor消元。每个点要么是
2024-09-14 12:43:52
1059
原创 AtCoder Beginner Contest 369 题解
A - 369#include<bits/stdc++.h> using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define ForkD(i,k,n) for(int i=n;i>=k;i--)#define Rep(i,n) for(int i=0;i<n;i++)#define ForD(i,n) for(
2024-09-01 21:53:26
1266
原创 Codeforces Round 969 (Div. 1) 题解
题意:给定一棵树,点权为0或1。定义一个叶子的权值为:考虑从根到叶子的这条路径的点权组成的字符串,权值为其中01作为连续子串出现次数减去10作为连续子串出现次数。定义树的价值为:权值非零的叶子个数(不包括root节点1)。现在一些点权变成 ?,博弈的两人分别填充,先手最大化,后手最小化树的价值。求最终树的价值。解法:一条路径计入答案当且仅当叶子和根权值不同。所以只和根和叶子的权值有关。若根的权值确定,则策略显然;若根的权值不确定,一个思路是看叶子节点填过的0和1哪个多,按自己的目标填;实际上当叶子
2024-08-31 12:42:46
1768
原创 BZOJ 五月胡乱补题
【BZOJ 3242: [Noi2013]快餐店】树形dp,要么最远点在同一颗树上(dp),要么在不同树上,此时答案=去掉任何一条边后形成的树的答案的最小值,我们枚举去掉的那条边。【BZOJ 4878: [Lydsy2017年5月月赛]挑战NP-Hard】染色问题,每次沿边染max,注意最后如果颜色数超过k,则可以按(k+1)-k-…由于答案=s[i]-s[j]+dis[i]+dis[j],i,j可以分开考虑,也可以用线段树解决。【BZOJ 4972: [Lydsy八月月赛]小Q的方格纸】前缀和。
2024-08-25 18:08:53
812
原创 AtCoder Beginner Contest 367 题解
B - Cut .0C - Enumerate SequencesD - PedometerE - Permute K timesF - Rearrange QueryYou are given sequences of positive integers of length NNN: A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N)A=(A1,A2,…,AN) and B=(B1,B2,…,BN)B=(B_1,B_2,\ldots,B_N)B=(B1,B2
2024-08-25 11:31:44
829
原创 UNIQUE VISION Programming Contest 2024 Spring(AtCoder Beginner Contest 346)
文章目录A - Adjacent ProductB - PianoC - ΣD - Gomamayo SequenceE PaintF SSttrriinngg in StringStringA - Adjacent Product#include<bits/stdc++.h> using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++
2024-04-16 22:28:54
770
原创 The 2nd Universal Cup. Stage 25: Shenzhen 题解
A good problem should have a concise statement.You are given an array a of length n, initially filled with zeros, and another array b of length n. Your goalis to transform array a into array b. You can perform the following two types of operations:• 1 x
2024-03-18 10:25:00
1289
原创 Hello 2024 题解
B. Plus-Minus SplitC. Grouping Increases给一个数列,不改变相对顺序前提拆成2个数列。问这2个数列中,相邻且前一个数小于后一个数的数对的最小值贪心,维护2个数列队尾的值,如果都会增加数对或都不会,则放到队尾数小的那个。不然放不会增加数对的那个。D. 01 Tree给一个树,所有非叶子节点均有左右2个子节点,边权分别0和1(可以对调)。已知所有叶子节点的按dfs序排列后的到根的最短路径长。问是否合法?dfs_order = []function dfs(
2024-01-13 19:32:58
1164
1
原创 Good Bye 2023 题解
sequence a, whose product was equal to 2023, k numbers were removed, leaving a sequence b of length n. Given the resulting sequence b, find any suitable sequence a and output which k elements were removed from it, or state that such a sequence could not ha
2024-01-11 10:41:14
1132
原创 Meta Hacker Cup 2023 Round 1 题解
给一个数列,要求分成若干组,要求每组至少2个数,使得所有组中位数的最大值与最小值之差尽量大,求这个值。Problem B1: Sum 41 (Chapter 1)Given a positive integer P, please find an array of at most 100 positive integers which have a sum of 41 and a product of P, or output −1 if no such array exists.If multipl
2023-10-19 22:33:25
430
原创 Codeforces Round 875 (Div. 1) 题解
A Copil Copac Draws Trees#include<bits/stdc++.h> using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define ForkD(i,k,n) for(int i=n;i>=k;i--)#define Rep(i,n) for(int i=0;i<n;i++)#def
2023-06-06 04:43:14
604
原创 The 1st Universal Cup Stage 13: Iberia, Apr 22-23, 2023 题解
D. XOR DeterminantYou are given two arrays b and c of length n, consisting of non-negative integers. Construct n × n matrixA as Aij = bi ⊕ cj . Find the determinant of A modulo 998 244 353考虑Aij=∑kbi,kcj,k+pA_{ij}=\sum_k b_{i,k}{c_{j,k}}+pAij=∑kbi,kcj
2023-05-03 14:42:04
1007
原创 The 1st Universal Cup Stage 12: ̄Ookayama, April 15-16, 2023 题解
A XOR Tree Path给一颗树,树上点有黑白两色,每次可以选一个叶子节点,翻转其到根路径上所有点的颜色,问最大黑色点数。树dp#include<bits/stdc++.h> using namespace std;#define MAXN (100000+10)#define ll long long#define F (100000000)#define Rep(i,n) for(int i=0;i<n;i++)#define next Nextint n,e
2023-04-17 22:12:17
458
原创 April Fools Day Contest 2023 题解
A Are You a Robot?print("security")B Was it Rated?#include<bits/stdc++.h> using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define ForkD(i,k,n) for(int i=n;i>=k;i--)#define Rep(i,n)
2023-04-12 20:41:31
506
原创 Codeforces Round 860 (Div. 2) 题解
A Showstopper#include<bits/stdc++.h> using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define ForkD(i,k,n) for(int i=n;i>=k;i--)#define Rep(i,n) for(int i=0;i<n;i++)#define ForD(i,n
2023-03-29 16:39:07
1147
原创 The 1st Universal Cup Stage 8: Slovenia, March 18-19, 2023(Differences-字符串hash)
找出一个串,和任何一个串Hamming距离均为为。考虑hash,给每个串随机分配一个随机数。为了保障成立可以多随机几次。表示第i个位置为字母。
2023-03-25 19:25:58
332
原创 THUPC2023 初赛(最后的活动-dp概率二分)
各位亲爱的《La Lumière: Scarlet Intense Flame》玩家:我们非常遗憾地宣布,《La Lumière: Scarlet Intense Flame》将于 2023 年 3 月 5 日 16:00 停止运营服务。停止运营相关时间表如下:……
2023-03-24 13:03:51
437
原创 The 1st Universal Cup. Stage 8: Slovenia.(Skills in Pills-dp)
Problem K. Skills in PillsInput file: standard inputOutput file: standard outputTime limit: 1 secondMemory limit: 256 megabytesAn unnamed protagonist of this task received amazing e-mail offers for wondrous pills that will enhancetheir cognitive and
2023-03-21 11:39:09
549
2
原创 洛谷 P2371([国家集训队]墨墨的等式-背包)
墨墨突然对等式很感兴趣,他正在研究∑i1naixib存在非负整数解的条件,他要求你编写一个程序,给定na1nlr,求出有多少b∈lr可以使等式存在非负整数解。
2023-03-15 08:40:41
162
原创 The 1st Universal Cup Stage 7: Zaporizhzhia, March 11-12, 2023(Determinant, or...?-子矩阵,det)
考虑这个矩阵刚好可以写成。这个性质 可以递归下去算。
2023-03-14 06:26:02
242
原创 THUPC2023 初赛(背包-同余背包)
本题中,你需要解决完全背包问题。有n种物品,第i种物品单个体积为vi、价值为ci。q次询问,每次给出背包的容积V,你需要选择若干个物品,每种物品可以选择任意多个(也可以不选),在选出物品的体积的和为V的前提下最大化选出物品的价值的和。你需要给出这个最大的价值和,或报告不存在体积和恰好为V的方案。为了体现你解决 NP-Hard 问题的能力,V会远大于vi,详见数据范围部分。
2023-03-12 07:07:34
762
原创 The 1st Universal Cup Stage 5: Osijek, February 25-26, 2023 题解
Problem G. GridlandiaInput file: standard inputOutput file: standard outputTime limit: 1 secondMemory limit: 256 megabytes给一个n∗nn*nn∗n的矩阵,每个格子可以选取上下左右一条边(可以不选),所有选取的边不能共点。现在要求构造一个方案,选尽量多的边。The continent of Gridlandia is a squares of side length n, div
2023-02-28 13:44:21
639
原创 The 22nd Japanese Olympiad in Informatics (JOI 2022/2023) Final Round 题解
交题:https://cms.ioi-jp.org/documentation给一个序列 a1,⋯ ,ana_1,\cdots,a_na1,⋯,an。执行nnn个操作,第iii个操作为找出第iii个数前离其最近且与它相同的数的位置,把这两个数之间的数全部赋值aia_iai。求最后的序列。考虑第iii个操作执行完后,iii之前每个数一定是连续出现正好一段或不出现。B给nnn个点对,每个点对(x,y)(x,y)(x,y)可以覆盖S=(a,b)∣b
2023-02-18 11:32:22
1236
原创 AtCoder Regular Contest 154 题解
给2个长度均为n的十进制数,你可以任意次交换2个数相同位置的数字,要求使它们乘积最小让其中一个数最小,另一个数最大。B - New Place给2个长度为n的串,每次可以把第一个串的第一个字符塞进这个字符串任意位置,问把这两个串变相同的最小次数。无解-1。有解当且仅当各个字符在2个字符串中出现次数相同贪心匹配第一个字符串中的后缀C - RollerYou are given sequences of positive integers of length A,BA,BA,BYou can rep
2023-01-23 00:30:31
1836
原创 Good Bye 2022: 2023 is NEAR 题解
Koxia and PermutationKoxia and Number TheoryKoxia and GameKoxia 和 Mahiru 正在用三个长度为 nnn的数组 a,b,ca,b,ca,b,c 玩一个游戏。其中 a,b,ca,b,ca,b,c中的每个元素都是 111到 nnn 之间的整数。游戏持续 nnn 轮。在第iii 轮中,她们进行以下操作:令 SSS是{ai,bi,ci}\{ a_i,b_i,c_i \}{ai,bi,ci} 的可重集。Koxia 从可重集 SSS
2023-01-01 00:00:53
568
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人