CodeForces
asdkjc
这个作者很懒,什么都没留下…
展开
-
Codeforces Round #658 (Div. 1)
A1.Prefix Flip (Easy Version) https://codeforces.com/contest/1381/problem/A1 A2.Prefix Flip (Hard Version) https://codeforces.com/contest/1381/problem/A2 大意是给两个仅由01组成的字符串a和b,长均为n,允许如下操作: 对一个字符串的1~ iii位分别取反后翻转 1 ~ iii位的位置。 举例,对100的1~2位操作后结果为100。 其中分别取反后为010原创 2020-07-23 00:45:10 · 220 阅读 · 0 评论 -
Ozon Tech Challenge 2020 (Div.1 + Div.2, Rated, T-shirts + prizes!)
contest1305 A.Kuroni and the Gifts 题意 给两个长度为n的数组a[],b[],保证在每个数组内任意两个元素不同,要求重新排列两个数组内元素使得对于任意i,ji,ji,j有ai+bi!=aj+bja_i+b_i!=a_j+b_jai+bi!=aj+bj,输出重新排列的两个数组。 思路 直接对两个数组排序分别输出即可。 AC代码 #include<std...原创 2020-03-04 21:59:28 · 141 阅读 · 0 评论 -
[CodeForces 1284C]New Year and Permutation(DP)
题意 若一个1 ~ n的排列中存在一个区间[L,R][L,R][L,R]使得这个区间内元素的最大值与最小值之差为R−LR-LR−L,则称其为一个片段,显然所有长度为1的区间均为一个片段。现在给定n与一个素数m,求1 ~ n的全排列中所有片段数之和对m取模的结果。 1≤n≤250000,108≤m≤1091≤n≤250000, 10^8≤m≤10^91≤n≤250000,108≤m≤109 思路 这...原创 2020-01-11 10:46:57 · 148 阅读 · 0 评论 -
[CodeForces 1254B1/B2] Send Boxes to Alice
大意 给你一个有nnn个非负整数(且至少存在一个正整数)的数组,问能否通过有限次给定操作使得数组内每个元素都能被某个大于1的整数kkk整除。若能,输出最小操作次数,不能则输出-1 操作有如下两种 对于1<i<=n1<i<=n1<i<=n,使aia_iai=aia_iai-1,ai−1a_i-1ai−1=ai−1a_{i-1}ai−1+1 对于1<...原创 2019-11-23 14:53:25 · 143 阅读 · 0 评论 -
[CodeForces 1108E1/E2] Array and Segments
大意 给一个长为nnn的数组和mmm个区间,第iii个数组元素为aia_iai,第iii个区间为[li,ri][l_i,r_i][li,ri]。选取一个区间的集合,对每个被选取的区间[lc,rc][l_c,r_c][lc,rc],使alc,alc+1,……,arca_{l_c},a_{l_c+1},……,a_{r_c}alc,alc+1,……,arc减1。 找出一种选取方法...原创 2019-11-23 14:02:09 · 121 阅读 · 0 评论 -
Educational Codeforces Round 73 (Rated for Div. 2)
A. 2048 Game 对于每种数字记个数,递推进位直到2048即可 #include<stdio.h> #include<map> #include<queue> #include<iostream> #include<algorithm> #include<vector> #define MOD 10000000007 ...原创 2019-10-02 17:22:05 · 136 阅读 · 0 评论 -
Codeforces Round #581 (Div. 2)
A. BowWow and the Timetable 题意 给定一个二进制数,求小于这个数的4的幂次的数量。保证没有前导零。 思路 二进制数中间找4的幂次两位两位比较就行了。只要知道串的长度,若为奇数再特判一下串中是否只有开头是1. #include<stdio.h> #include<map> #include<queue> #include<iost...原创 2019-08-21 09:59:31 · 151 阅读 · 0 评论 -
[CodeForces 372C] Watching Fireworks is Fun (DP+单调队列优化)
题面 大意 在一条街道上有nnn个位置分别为111~nnn,有mmm个烟花,给出每个烟花的位置aia_iai和燃放的时间tit_iti,以及bib_ibi值,当烟花燃放时,你在街道的x(1=<x<=n)x(1=<x<=n)x(1=<x<=n)位置上获得的快乐值为bib_ibi-∣ai−x∣\vert a_i-x\vert∣...原创 2019-08-09 17:30:56 · 174 阅读 · 0 评论 -
Educational Codeforces Round 62 E. Palindrome-less Arrays
Examples input 2 3 -1 -1 output 9 input 5 2 1 -1 -1 1 2 output 0 input 4 200000 -1 -1 12345 -1 output 735945883 题意 给出一个长为nnn的数组,数组中的每个元素要么是111$k$要么是$-1$,任务是统计将所有的$-1$用$1$kkk的数填入之后不产生长为奇数的回文串的填法之...原创 2019-07-22 15:00:51 · 114 阅读 · 0 评论 -
Educational Codeforces Round 67 D. Subarray Sorting
Example input 4 7 1 7 1 4 4 5 6 1 1 4 4 5 7 6 5 1 1 3 3 5 1 1 3 3 5 2 1 1 1 2 3 1 2 3 3 2 1 output YES YES NO NO 题意 有ttt组询问。 每组询问给出一个nnn以及长为nnn的a[]a[]a[]和b[]b[]b[]数组,每次可对a[]a[]a[]数组内任意一个区间进行由小到大的排序,...原创 2019-07-22 10:56:33 · 74 阅读 · 0 评论 -
Educational Codeforces Round 69 (Rated for Div. 2) C. Array Splitting
题目链接:http://codeforces.com/problemset/problem/1197/C 大意 给一个长为nnn的单调不下降数组,将数组划分为k段,使得每段的【最大值与最小值之差】之和最小。 思路 乍一看没什么头绪。 (去吃了个饭) 仔细思考后发现设第kkk段开头为ala_lal,结尾为ara_rar则这段的最小值与最大值之差可以表示为((a((a((al+1−a-a−al)+...原创 2019-07-24 17:23:12 · 152 阅读 · 0 评论 -
Codeforces Round #573 (Div. 2) F. Tokitsukaze and Strange Rectangle
F. Tokitsukaze and Strange Rectangle time limit per test:3 seconds memory limit per test:256 megabytes input:standard input output:standard output There are nnn points on the plane, the iii-th of whic...原创 2019-07-16 16:21:59 · 129 阅读 · 0 评论