Happy Easter, Codeforces! Sadly the round will not be Easter themed :(
We (arvindf232, culver0412, snowysecret, AHappyPotato, jerryliuhkg) are delighted to invite you to participate in Codeforces Round 865 (Div. 1) and Codeforces Round 865 (Div. 2), which will take place on 09.04.2023 17:45 (Московское время). Participants with a rating lower than 1900 will participate in Division 2, while participants with a rating of at least 1900 will participate in Division 1. Notice the unusual starting time.
All the problems were authored and prepared by arvindf232, culver0412, snowysecret and AHappyPotato. Huge thanks to the following people, without whom the round would not be possible:
- Artyom123 for excellent coordination and translation of statements.
- KAN for help with round preparation.
- jerryliuhkg for problem proposals which didn't make it to the final problem set.
- gamegame, dorijanlendvaj, abc864197532, ShuiLaoshi, ACGN, Rekaxem, xiaoziya, Perpetually_Purple, prvocislo, Qingyu, JeffreyLC, wyhong3103, Nahian9696, NemanjaSo2005, Dakto, triple__a, Singinginginging, Imakf, Ritwin, TomiokapEace, dbscts, mariowong123, jerryliuhkg, Flower08, Codula, prabhav_, rsj, __jk__, Aaeria, DBSHoShunNgai, Tutis, ak2006 for testing and valuable feedback.
- rsj for providing a nicer solution to one of the problems.
- MikeMirzayanov for Codeforces and Polygon platforms.
- You, for participating!
In both divisions, you will have 2 hours and 15 minutes to solve 6 problems. One of the problems is interactive, please see the guide of interactive problems if you are not familiar with it.
Wish you good luck and high ratings!
UPD1: Score distribution is as follows:
- Div. 1: 500-1250-1750-2500-3000-3500
- Div. 2: 500-1000-1250-2000-2500-3250
UPD2: Editorial
UPD3: Congratulations to the winners!
As a free-riding tester, give me contribution.
slavicg pfp deserves contribution :)
As a tester, video editorials for some problems will be available on my channel after the contest.
As a tester,
Same as above comment.
As a co-author, please give me contribution!
As a co-author, please give me contribution!
As a tester, this is my first testing round! Good luck guys!
As a tester I forgor to test 💀
As a participant , I can confirm Perpetually_Purple orz
Perpetually_Purple ORZ!
As a tester, I can't think of anything funny to put here.
two-four-five particle
Unusual time with least deviation.
Time To Tourist To Go To First Pos AGain
You're right. But I hope jiangly's rating can exceed 4000 as soon as possible!
Is it possible to reach 4000 if one get 1st in div1 everytime?
Rank 1 performance in div 1 is higher than 4000, so yes it is possible!
Wait, you really can somehow lose rating if winning div1??
If I remember correctly there was a round where in the middle tourist ranked first, tied with another user, and tourist's delta was shown as negative.
When i click to register div1 codeforces gives this "Rating should be between 1900 and 9999 in order to register for the contest XD.
What all Think if jiangly reaches 4000 does some new name comes or or something cool happens kind of international legendary grandmaster
I think it will be full black color
No, that is reserved for headquarter members
As a downsolver, I can confirm that authors put a lot of work into this round and I hope you enjoy it.
So, if you solve problems after the contest it is called upsolving. But as a tester, I was solving them before the contest, so I guess that is downsolving. Not sure if it has some other meaning.
As a participant, I will appreciate the work of authors and testers. Thank you for the contest!
Sadly the round will not be Easter themed :(
Please add more contests.
culver0412 orz
As a non tester,I will also enjoy this round:)
As a non-tester, I will enjoy easter :)
As a tester, I am not a tester.
why only 1900+
Since your rating is lower than 1900, you are in Division 2.
Happy Easter, Codeforces! Sadly the round will not be Easter themed :( (in White) , Excited for the Contest
As a non-tester, I want to be a tester.
As a non-tester,i want to ask how can i become a tester one day
i still remeber the last edu codeforces,which unr because of test mistake
I will just copypaste my comment from a recent blog:
If you are a tester, most likely, you are invited by one of the authors. So do you know any round authors? If you don't, there is an alternative solution: be a round author yourself! Some coordinators and authors will invite authors of previous rounds as testers.
Hi can I test?
thanks, i understood
But the question now is, how does one become a round author? :P
Well i am more excited to watch tourist Vs jiangly, this time.
what kind of question is the first one
-
yes bro , if they highlighted the lattice points it would have been better to understand lol
Huge separation between C and D today in pure Div 2 lol
So TRUE.... unbalanced DIV2 Again :(
Pupils after overthinking C
completely agree :(
im green but its so true to me
Tourist The King ! Again on top
but jiangly still above
most stupid div2 contest ever, B and C are both some quasy patterns with no proof of why it should ever work other than that it is a pattern that could apply in codeforces contest
I think C was a little pretty, I didn't like B though.
Both are provable
Agree about B, but C can be solved with a simple greedy algorithm which can be easily proved.
How to proove it pls
write final vector as an initial vector plus some vector from space spanned by vectors of form $$$(0, .., 0, 1, 1, 0, .., 0)$$$ (two consecutive ones somewhere). Then you can write out constraints on the coefficients, notice that if $$$n$$$ is odd you can find such coefficients always, and if it's even you can check in linear time if these constraints are satisfiable with the given $$$a$$$ vector.
Any idea on how to prove B?
https://codeforces.net/blog/entry/114847?#comment-1021798
I like interactive problems but this was extremely hard to understand
DID YOU ALL NOTICE?? There is a highlighted text while selecting the first line of the blog... "Happy Easter Codeforces" one, extend it further from left to right!!
Spent about 1 hr on div2D and finally figure it out but couldn't implement it in time.
Congratulations to YocyCraft for becoming GM after this round, assuming you pass system tests!
Thanks for an amazing contest! Solved D1A, B and C, got 160th and +107 delta according to carrot. Definitely my best performance ever. I really loved the style of problems and statements were clear and consise, straight to the point with no unnescessary stories. I would honestly love to see more contests from you as soon as possible!
What was Test 2 in Div1-C ?
D1C is overwhelming, and D1D is also nice! Thanks for the great round!
Sorry I got FST on D with $$$m=1$$$, so sad
Div1 B
https://codeforces.net/contest/1815/submission/201562137
This submission get WA on test1, but why?
I tested it by myself, the result was allright.
I tried testing your code manually, and this is what I got, perhaps there was some miscalucalcution in answering the queries as per the interaction, the same happened with me before and it was frustating :')
Guys, is Div2 C binary search?
No, at least I don't see it
No
Then how to do C?
I just did two iterations over the initial array.
In the first iteration we check if a[i] > a[i+1]. If that is the case then we increment both a[i+1] and a[i+2] until a[i] = a[i+1].
For the second iteration we go from behind and check if a[i] < a[i-1]. If that is the case then we decrement both a[i-1] and a[i-2] until a[i] = a[i-1].
If the array we get is non-decreasing, the answer is YES, otherwise NO.
A,B,C problems were good enough....But, hardness(D-C)=inf...
What was the intended solution for div2A? I couldn't think of anything and figured brute force would probably result in around sqrt(n) complexity by brute forcing until I find an I such that gcd(x-1, abs(y-i)) = 1. This ended up working for me.
Probably something like $$$(0, 0) \rightarrow (1, b-1) \rightarrow (a, b)$$$ (I can't be bothered to think if there are any edge cases to this)
Just realized that's why my solution passed so quickly, my loop started at 1 which was always an answer lol.
it can be solved O(1) TC...exmple, two points are: (a-1,1) (a,b)...
mesosan orz
mesosan orz.
Can anyone tell the idea behind the problem C.
if n is odd then answer always exist...otherwise carefully notice that you can just transfer value from even pos to even pos and odd pos to odd pos...so compare between sum of even pos ans odd pos...
Let b(i) be a number added to a(i) and a(i+1)
Then you can find equations of b(i)s from the non-decreasing condition
if n is even
a(2)-a(1)+a(4)-a(3)+...+a(n)-a(n-1)>=0
if n is odd
No condition
How to become better at these type of problems.
Detail solution to Problem C: Link
D problem ORZ
Problem C from Div. 2 is somewhat similar to Drought from the USACO 2022 January contest.
how to solve div2A?
move to (a-1,1) then move to (a,b)
10 wrong submissions 💀 💀
Div 2 F :skull:
Solution for Div1B:
Do $$$"+ n","+ (n+1)"$$$,you'll get a chain.
Do $$$"?1,i"(2 \leq i \leq n)$$$,you'll get a endpoint $$$e$$$ of this chain.
Do $$$"?e,i"(1\leq i \leq n ,i \neq e)$$$.Sorted by distance, we get the entire permutation.
Is this logic incorrect for D1C: Firstly all vertices should be reachable from 1 in the graph with reversed edges, else the number of sequences are infinite. Then I find out SCCs. The SCC containing '1' has a sequence: [s2,s3,..sk] + [1] + [s2,s3,..sk]. Then in topological order we build other sequence for other SCCs.
I did A,B,C pretty easily. But in D what was that permutation about, we had to guess it but what that permutation really meant ?
Even after spending 30 mins I couldn't understand the permutation. Please explain.
do + n and + (n+1), you can get a chain. then it's much easier to get relative order of nodes on the chain
The permutation just exists. It doesn't affect the construction of anything else. The only way to get information about the permutation is by doing type $$$2$$$ queries. The permutation exists as a mapping of integers to other integers (nodes) when doing type $$$2$$$ queries and you need to figure out what that mapping is.
Interaction details are very annoying... missed the problem due to that :d... input 1 if it is correct or -2 if it is not... did you really need to do that?
I also missed that :(((
I also thought like you.
In case anyone's wondering, the "hack" in Div1D is not taking modulo when printing the answer for $$$m = 1$$$.
That's pretty silly. There was an OpenCup contest around 2018 from Red Panda where "output something modulo $$$M$$$" was defined as "you may print any number that is congruent to the answer modulo $$$M$$$".
I think that should become the standard. Add some extra helper functions to testlib.h and it wouldn't be very hard to do that way in every contest.
I totally agreed with this. I would be pissed if my entire solution failed because of such case. Feel bad for the guys I hacked because they couldn't fix their codes in time :(
How to solve Div-2C today's contest?
If the array is already sorted , we’re done and answer is yes. If the array size is odd the answer is always yes ,proof: we can make the first n — 1 elements equal to the first element by applying operations on every two adjacent elements a[i] and a[i + 1] for 1 <= i < n — 1. We will have x x x x .. x x y where the number of x's is (n — 1) which is even , since have even number of x’s we can decrease all of them if they are greater than y by dividing them into pairs and applying the operation on each pair.
If the size is even We will do the same and try to make the first n — 1 element equal by doing the same work above , but then we will have odd number of x’s so we cannot decrease them , the only possible way for the answer to exist is if y >= x.
201571830
The format of interactive problems is very bad. You get random verdicts and notes from checker and can't understand, what you did incorrectly. I spent 50 minutes to submit already correct solution, which did queries incorrectly. And for "Is it possible to get for all queries non-negative answers, but get WA for test?", the answer is not "No comments", but "Yes, it's possible" (if you print not permutation at ! operation).
The problem $$$B$$$ is nice though. Notice, that you can create a bamboo (or spagetti?) in three moves. Then using $$$n - 1$$$ moves find one of its ends. But you can't understand, which one you found, so track both cases. Then in $$$n - 2$$$ find $$$n - 2$$$ other numbers of permutation. You have no query to find last one, so do it manually.
You can create bamboo even in two moves. add(n) and add(n+1)
still sad for the last edu codeforces which is unrated
i should earn 100+rate on that round
and even 20 rate will surely make me CM this time
Solution for Div1C:
Define finite number:
$$$1$$$ is finite number;
if $$$v$$$ is a finite number and $$$(u,v)$$$ exists,$$$u$$$ is also a finite number.
We have discovered a directed graph. Starting from $$$1$$$ for BFS, if there is a number that is not finite, no solution.
We also note $$$dis[i]$$$ as the shortest distance from point $$$1$$$ to $$$i$$$.
Obviously,for all $$$i$$$ that $$$dis[i]==1$$$,There can be at most $$$2$$$ numbers in the sequence.
Similarly,or all $$$i$$$ that $$$dis[i]==x$$$,There can be at most $$$x+1$$$ numbers in the sequence.
Construction:A bit complex. I implemented it using a linked list.
I messed up on this problem because I assumed that cycles would lead to an infinite series.
Easy construction:
Let $$$max_{d}$$$ equal the maximum value of $$$dis[i]$$$
The answer sequence is as follows:
$$$[[max_d], [max_d-1], \dots, [2], [1], [0],$$$
$$$[max_d], [max_d-1], \dots, [2], [1],$$$
$$$[max_d], [max_d-1], \dots, [2],$$$
$$$\dots$$$
$$$[max_d], [max_d-1],$$$
$$$[max_d]]$$$
where $$$[n]$$$ gets replaced by a sequence containing one of every integer $$$i$$$: $$$dis[i] = n$$$
Thx,it's pretty neat!
Construction: Let $$$S_i$$$ denote the sequence of points at distance $$$i$$$ from $$$1$$$, ordered arbitrarily. Let $$$K$$$ be the largest distance any point has from $$$1$$$. Then the following construction works:
$$$(S_K + S_{K-1} + S_{K-2} + \cdots + S_{0}) + (S_K + S_{K-1} + \cdots + S_{1}) + \cdots + (S_{K} + S_{K-1}) + (S_{K})$$$
$$$+$$$ denotes sequence concatenation
I guessed all the questions I solved today :clown:
Div 2. A, B had good samples so no penalties
Died in C penalties ;-;
:clown: I was in the first 60 solves for C and had 0 penalties then took 2h for A and B with 4 penalties
I was in the top 300 after solving A and B and then couldn't solve C :)
you think that's bad, realized after the round that my code for C wasn't passing because of a int overflow :(
can someone explain the logic behind B? I just saw a random pattern in testcases and printed it.
Can someone give a formal proof along with the method for B. I was clueless about how to approach this question. Thanks
You always start at (1, 1), so it's added and it should be maximum possible. Note also, that you when you end at (2, $$$n$$$) you add that number too, since $$$n$$$ is even, so it should be second biggest number.
Now, when you start at (1, 1), you go either right or down, and both these values are on minus, so we should minimize them, so put at (1, 2) and (2, 1) 1 and 2 respectively. Now, when you are in either of those cells you can go to (2, 2) or (1, 3) where you maximise. Then you will end up in either (2, 3) or (1, 4), which you minimize, and this goes on and on.
I haven't proven it but consider these observations.
There are some squares that contribute positively to the sum, and some that contribute negatively. These different types of squares form a checker pattern.
For each of the squares that contribute positively that are in the top row, we can go to two squares that contribute negatively, either the square under it or the square that is to the right.
Since we want to maximize the minimum sum, it would be a good idea to get as little fluctuation in the different answers we can possibly get in the end (again, this is not a proof just observations), so we should put two consecutive numbers in those two negative squares so that if we choose either of them, the difference in the sum they make is at most equal to 1.
So we want to put the biggest half of the numbers (from n+1 to 2*n inclusive) in the positive squares, and the smallest half (from 1 to n inclusive) in the negative squares.
The last thing is that we should put the biggest two numbers at the positions (1, 1) and (2, n). This is because we want the biggest numbers to be included in every single path possible.
can anyone give some idea related to div2b
The blue cells will be the positive integers so you need to maximize the integers in the blue cells in a certain order
Can anybody give me a test case for div2 C where my solutions is failing. Thanks.
Submission = link
The main code is as follows:
Try this test case 1 7 1 1000000000 1 100000000 1 1000000000 1
Thank you so much. I was still trying to figure it out.
For div2F/1D, sequence for m = 2 is available here. https://oeis.org/A328565. (m != 2 is trivial)
We can get the nth term (a direct formula isn't specified) using the structure in https://oeis.org/A328565/a328565.png, which says if a given xor y can be achieved given n. Now we can form a recursive equation to get answer for a big n.
Div2 D is totally a disaster it's far harder than C(even harder than E,i think)
abcforces
problemsforces
Solved Div1 A-C. Give me >=51 delta plz.
D1A/D2C: Let d[0]=0, d[n]=0, and d[i]= how many times we do operation on pair (i, i+1) (decreasing is regard as -1 operation), then we have a[i]+d[i-1]+d[i]<=a[i+1]+d[i]+d[i+1], which means d[i+1]>=d[i-1]+(a[i]-a[i+1]), so we have an inequallity system. If n is odd, this inequallity has a solution, but if n is even, we have 0=d[n]>=d[n-2]+(a[n-1]-a[n])>=d[n-4]+(a[n-1]-a[n])+(a[n-3]-a[n-2])>=...>=d[0]+(the alternative sum of a)=(the alternative sum of a), so we need to check whether the alternative sum of a is non-positive.
D1B/D2D: If we add edge for x=n and x=n+1, the graph will become a path: n --> 1 --> n-1 --> 2 --> n-2 --> 3 --> ..., so we can query (1, i) for 2<=i<=n to get the furthest point from p[1], and it must be one of the endpoint of this path. Let j be the furthest point then we can query (i, j) for 1<=i<=n, i!=j and we can get the order of p[i] on this path. The answer will be this order or its reverse order.
D1C/D2E: Let's build a directed graph with node numbered 1...n, and add an edge (b-->a) for each pair (a, b). Note If there's any number cannot be reached from 1, we can build an infinite sequence: Let c[1], c[2], ..., c[r] be the set of numbers cannot be reached from 1, the infinite repetation of (c[1], c[2], ..., c[r]) will be a valid answer. Otherwise, we can group numbers by the distance from 1. If the maximum distance from 1 is k, and we denote the list of i-dist numbers as L[i], we can build a sequence as L[k], L[k-1], ..., L[0], L[k], L[k-1], ..., L[1], L[k], L[k-1], ..., L[2], L[k], L[k-1], ..., L[3], ..., L[k], L[k-1], L[k-2], L[k], L[k-1], L[k]. We can see for any pair of same numbers with distance i, there are occurences of all numbers with distance >=i-1 (except itself) between them, and by the defination of distance, for any pair of (a, b), because there's an edge (b-->a), we have dist[b]>=dist[a]-1, so this is the valid answer. And we can see that each number with distance k can have at most k+1 occurence in any valid sequence (that's because between k+2 numbers of distance k there are at least k+1 numbers of distance k-1, k numbers of distance k-2, ... , 2 numbers of distance 0, but the only number with distance 0 is 1, that's a contradiction), so this is an optimal answer.
GM YocyCraft
GM YocyCraft
when is the next contest MikeMirzayanov sir?
There may be an alternative solution for Div1B to get a unique permutation using $$$\approx 1.5n$$$ queries for sufficiently large $$$n$$$.
First,
+ n
and+ (n - 1)
to get the vertices $$$1, 2, \ldots, n - 1$$$ connected like a chain. This takes $$$2$$$ queries.Then, we would like to find $$$x$$$ so that $$$p_x = n$$$, the isolated vertex, in this part. To do so, we may take any two indices $$$i, j$$$ and ask
? i j
, if the response is non-negative, eliminate both of them from the candidate list; otherwise, exactly one of $$${p_i, p_j}$$$ must be $$$n$$$. We can find which it is by just asking? i k
with any $$$k \neq j$$$. This takes up to $$$\left\lfloor \dfrac{n}{2} \right\rfloor + 1$$$ queries.Do
+ (2n - 1)
so that vertex $$$n$$$ is connected to vertex $$$n - 1$$$. Now, the graph forms a chain. This step takes $$$1$$$ query.By asking
? x z
, $$$\forall z = 1, 2, 3, \ldots, n$$$, the permutation can be uniquely determined since each response is distinct. This takes $$$n$$$ steps.Directly implementing this solution would fail for $$$n \leq 6$$$. But as you can see, there are many apparently redundant queries in some steps.
My idea was similar with $$$n + \lfloor \frac{n}{2} \rfloor + 2$$$ queries total.
It also gets AC(201561852) but need some optimizations.
Great, that's an interesting idea! I think some co-author / tester mentioned the existence of a $$$1.5n$$$ solution during the round preparation. Maybe the problem could have been split into an easy and hard version, but it seems like the current version is difficult enough.
This idea has been linked in the official editorial as the "harder version". Thank you!
sorry for necroposting , but I didnt get why would your approach fail for n <= 6 like for n = 5 you would first update 5 and 4 , so right now graph is smthng like 4 — 1 — 3 — 2 5 in worst case it would take us 2 queries to figure out the isolated vertex and we would need one more to connect 5 with 4 (query : 9) till now we used 5 interactions , after these we can use 3 more queries to find the position of each index
so why would 8 queries fail ? ( ok Im stupid for n = 5 it took 9 queries , ig as n gets smaller we will get higher interaction numbers )
For problem D1B/D2D's interaction format, our intent was to prevent unexpected verdicts caused by wrong output format or exceeding number of operations, since we can tell the contestant to terminate the program and receive Wrong Answer.
However, some issues arised, such as some contestants forgetting to read the integer $$$1$$$ or $$$-2$$$ depending on whether the answer is correct. If they didn't read it, they are effectively solving the next query with $$$n=1$$$ which causes some errors unexpected by the contestants. Although the statement was bolded in the statement, it turned out that it was still not too obvious for everyone :(
Lots of contestants asked about self-loops. We did not expect that confusion, since the distance from a node to itself is always $$$0$$$, but we should have explained that clearer in the statement. Sorry about that.
Other than the somewhat complicated interaction format and unclear details, I hope you still enjoyed the problems.
Good problems especially problem D!
Div2 D (Div1 B) is a little vaguely worded. It did not explain the case for query
? i i
. I thought this would return 0 iff there is a self-cycle from i to i (and -1 otherwise). So I constructed an algorithm that should be similar to the correct solution:I should have used the question feature, didn't think about that. The reality is "? i i" always returns 0. This is very confusing because in the example, n=6 and there was a query "+ 12". So this query is entirely useless, and potentially misleading (I thought self-cycles are useful). I tried 11 submission with different
throw()
to test out what went wrong. After I finally found out I didn't even want to code anymore. Very frustrating for me.P.S. Other than this, great contest! Lots of constructive algorithms.
If you have any problems regarding the statement, you can use the ask a question feature. A lot of the questions asked are regarding the
? i i
case, we think that it might have been confusing to most of the contestants.Hope you still enjoyed the other problems!
Yeah I never used that before so didn't think about it. Will make sure to do it next time.
For some reason didn't enjoy neither of ABC =(. Maybe simple observation/construction problems aren't to my taste. But most probably the reason is I am just bad at math
I agree. I barely managed to solve them because I kept tripping up on them. :/
Today D was much harder then regular D
Problems were very cool authors! I really enjoyed D1B-D1D.
Although I'd say B > C > D in terms of difficulty personally and seems I would've FST on the D hack if I did finish it in time which is unfortunate for those that did.
Great job overall still, hope to see more from you guys in the future!
201512259 Can someone please tell why it failed on Problem A ??
For test case:
it gives
which is wrong since the line joining (0,0) and (6,8) also has other integer co-ordinates lying on it. For example, (3,4).
I am new to the website. I participated in this contest in Div 2, with account rating of 540, and it looks like it is unrated for me. Why ? Please explain to me
It takes some time for ratings to update.
How do you rigorously solve Div 2 B? I was able to intuitively guess the correct pattern, but couldn't prove that it was optimal.
Just realized my code in problem C wasn't passing because of a int oveflow fml
What is the logic behind div2 C. I am completely blank on this one. I've seen some solutions which use left to right traversal and right to left traversal. But m not sure how to prove it. Can someone give a solid solution. Thanks UPD: Got it! thanks for the replies
My approach If you tried to see there are two cases for n even and n odd.. for n is odd it is always possible to make array sorted, you can try every different possible case for n is odd. I have not proved it but by intution, I can say I have one extra element when n is odd which is helping to sort the array every time.
I just implemented for second case.
for n even what i did, I just simply traversed an array an start making it sorted by doing the operations given, If at end i got sorted array then yes, othewise no. let see how I did if array is [3,2,5,4]. what I did I first convert first element two 1; [1,0,5,4] by subtracting 2 from first element and second element.
[1,2,7,4] by increasing 2 to second and third element.
[1,2,3,0] by subtracting 2 from third and fourth element.
Now I am at index 2,I can't perform any operation further. I can't increase 0 by any means, I just checked is it sorted or not.
For N=odd, the idea is that if you have a bad index
i
where A[i] < A[i — 1], then ifi
is odd, A[1:i-1] has have even length, and you can decrease these values pairwise until A[i-1]=A[i]. Otherwise,i
is even, and A[i:N] has even length, so you can increase A[i:N] to achieve the same result.Example:
This way, you can remove any bad index without introducing any new ones.
How about the case 1,7,8,6?
You can reformulate the problem in the following way :
given an array of $$$n$$$ integers $$$a_1 , a_2 ,.. , a_n$$$
check if there exist some array of numbers $$$k_0, k_1 , ... , k_{n}$$$ such that the array:
$$$a_1 + k_1 , a_2 + k_1 + k_2 , ... ,a_{n-1} + k_{n-2} + k_{n-1} , a_n + k_{n-1}$$$ is sorted in non-decreasing order.
That means that : $$$a_1 + k_1 \le a_2 + k_1 + k_2 \le ... \le a_{n-1} + k_{n-2} + k_{n-1} \le a_n + k_{n-1}$$$
We can assign $$$k_n = k_0 = 0$$$
We have a system of inequalities : $$$k_{i-2} + a_{i-1} - a_{i} \le k_i \le k_{i+2} + a_{i+2} - a_{i+1} \ \forall \ i \in [1 , n-1]$$$
So we can assign $$$k_i$$$ to its maximum value $$$k_i := k_{i+2} + a_{i+2} - a_{i+1}$$$ and in particular $$$k_{n-1} = +\infty$$$
After doing this process we have to check if $$$k_0 \le a_{2} - a_1 + k_2$$$
Code : 201581485
here's my understanding: Let's assume N is even. We should end up with
a(1) <= a(2) <= .... <= a(N)
, which in turn means thata(1) <= a(2)
,a(3) <= a(4)
, ....,a(N-1) <= a(N)
should all be true.Summing up
a(1) + a(3) + ... a(N-1)
<=a(2) + a(4) + ... a(N)
. Let's say initially before operations are applied,Sum(odd)
=a(1) + a(3) + ... + a(N-1)
andSum(even)
=a(2) + a(4) + ... + a(N)
. Also let's note that increasing/decreasing consecutive elements ofa
by 1 doesn't affect the value ofSum(even) - Sum(odd)
. So ifSum(even)
was initially greater thanSum(odd)
, it will always be.Now if
Sum(even) >= Sum(odd)
, there is a solution:0, 0, 0, ..., 0, Sum(even) - Sum(odd)
(N-1
times zero and thenSum(even) - Sum(odd)
). On the other hand, ifSum(odd) > Sum(even)
, then one of thea(1) <= a(2)
,a(3) <= a(4)
, ....,a(N-1) <= a(N)
should become false. (OtherwiseSum(odd) <= Sum(even)
Now let's assume N is odd. Now we have
a(1) <= a(2)
,a(3) <= a(4)
, ....,a(N-2) <= a(N-1)
. Notice thata(N)
doesn't participate in above inequalities, but it does contribute tosum(odd)
. In this case, we can turn initial sequence to-inf, 0, 0, 0, ...., 0, Sum(even), inf + Sum(odd)
, which will satisfy all requirements, whereinf
is very large number.Auto comment: topic has been updated by culver0412 (previous revision, new revision, compare).
which div2 was tougher in your opinion ?
from last two.
For me personally, this one. While I loved the round, expecting around -150 delta, while last round was close to +100.
Thanks to the authors for the amazing problems. I had fun solving D2A, and, D2B during the contest, and up-solving D2C. Will be trying D2D next.
Can someone please explain proof of B in editorial in more detail?
In particular, I would like to know what does it mean lowerbound for maximum cost and how do we, from the observations in proof before that, conclude that this is the value of the lowerbound.
In task we need to construct the grid such that minimum cost over all paths is maximized. So I think in order to prove that some construction satisfies the requirements we need to find value C(n) such that for every placement of integers on the grid minimum cost among all paths in the grid is <= C(n). Then we need to show that for our construction minimal cost equals C(n). Am I wrong?
Let T be the top path which moves right n times and moves down at the end, and let B be the bottom path which moves down first then moves right n times. For a path P let C(P) be its cost.
Now color the grid with a chessboard colouring so a square (i, j) is black if and only if (i + j) % 2 == 0. Then we have:
C(T) + C(B) = (sum of the numbers on the black squares) — (sum of the numbers on the white squares) + (value at (1, 1)) + (value at (n, 2))
Now what is the maximum value of the right hand side? We should make the numbers on the black squares as big as possible, so take n + 1, ..., 2n, and we should make the numbers on the white squares as small as possible, so take 1, ..., n. The squares (1, 1) and (n, 2) are both black and counted twice, so we should make them as big as possible as well, so we take them to be 2n and 2n-1.
In this optimal situation, the right hand side is ((n + 1) + .... + 2n) — (1 + ... + n) + 2n + 2n-1 = n^2 + 4n — 1. So in any configuration we have C(T) + C(B) <= n^2 + 4n — 1, so we either C(T) or C(B) is <= n^2/2 + 2n — 1, and so this gives an upper bound on the maximum min cost path.
And then there are many ways to prove this bound can be achieved. You just have to come up with some pattern and check that all of its paths have cost at least n^2/2 + 2n — 1. Necessarily the top and bottom paths in an optimal configuration would have to have costs n^2/2 + 2n — 1 and n^2/2 + 2n, so that immediately constrains the search. For example, one pattern which I'll illustrate for n = 6 is to take
12 2 10 4 8 6
5 7 3 9 1 11
Thank you, I understand it now.
No more contests in the coming week?
I'm struggling to understand Div2D's example. How does
[1 2 3 4 5 6]
comply with the query about $$$p_1$$$ and $$$p_3$$$? The distance between nodes 1 and 3 is 2 in the graph at that time.Thanks for the great contest! D was such a cool problem. It was one of those problems where you jump up from your seat when you figure it out.
Why there is no upcoming contests ?
We really want more CF rounds!
is this unrated?
this is not unr
just wait
864th contest was rated too fast!!! Why it is taking delay?
i miss my photo so much
thank you codeforces
As Rating of Div 1 is already updated but why there is delay in Div 2 rating update?
I'm also wondering.
This round was really good!
Please MikeMirzayanov fast :)
when will the ratings update :( . I have started to feel like they will make this unrated.
As a tester im testing your patience u could show in the comment section
SlowRatingForces
Why does this round unrated for div2?
i suppose this is just slow ,maybe they are bussy now ,but it make me feel not good that they update the rating change for div1 already , but just don't update for div2
the system has already finished , it isn't testing now , will it roll back?
nice div2 hope no interactive problem next time XD
Was this round, rated for Div 2 , cause the last one 864 div 2, showed rating much earlier
Make up for the evaluation time difference XD
So when can we expect for updated ratings
As a newbie, I'd like to share my solutions to Div.2 ABC. I solved all three problems in a constructive way.
Problem A: The statement "jumping from one lattice point to another without touching other lattice points" directly hints that the delta x and delta y of the jump should be relatively prime. However, it's impossible to traverse all the possible jumps. I tried several cases and the cases where the delta x or delta y equals 1 caught my attention, e.g., (1, 3) and (4, 1). I realized that two jumps that form an "L" shape would always be possible. Solution: 201604536.
Problem B: I misunderstood the problem at first, thinking the path will traverse all the points and gives an easy construction[submission:201606323]. I got WA and read the statement again. I realized that the path with minimum cost was not required to go through all the points. I studied the sample cases and found the answer has some fixed patterns. - P1: Each grid with the coordinate (1, 2k — 1) or (2, 2k) will contribute a positive term to the loss while grids with the coordinate (1, 2k) or (2, 2k — 1) will make negative contributions. To maximize the minimum loss, we can put n + 1, ..., 2n to grids with the coordinates (1, 2k — 1) and (2, 2k), and put 1,..., n to grids with the coordinates (1, 2k) and (2, 2k — 1). - P2: The path with minimum loss should not go down more than once. Based on P1, each time the path goes down, it will get an additional positive cost. So the path with the minimum cost should go down only once, i.e., (1,1) to (1, n) to (2, n) or (1, 1) to (2, 1) to (2, n). Note that this has not been proved rigorously. - P3: The path will always go through (1, 1) and (2, n). So we can put 2n and (2n-1) into these two grids. To maximize the minimum cost, we put -1 and -2 to (1, n) and (2, n-1), as the path will always go through one of them. For the left -3, -4, ..., n and n+1, n+2,..., 2n -2, to maximize the minimum cost, we pair them evenly, e.g., (-3, n + 1) and (-4, n + 2), and put these pairs into adjacent grids. Solution: 201608912.
Problem 3: This a tough one for me. I was not following the editorial and thought about a[i+1] — a[i]. Instead, I start with sequences with a length of 3. I found it is always possible to reach a solution. Moreover, we can always get a solution with three same numbers. For example, with a sequence {a1, a2, a3}, we can make it {a1, a1, a3'} by adjusting a2 and a3. Then we can get {a3', a3', a3'} by adjusting {a1, a1}. Based on this observation, we can extend to sequences with a length of 5. For example, with a sequence {a1, a2, a3, a4, a5}, we can first get {a3', a3', a3', a4, a5}. Then for {a3', a4, a5}, we can also get {a5', a5', a5'}. Then by adjusting {a3', a3'} to {a5', a5'}, we can get {a5', a5', a5', a5', a5'}. We can extend this construction to all the sequences with an odd length. So, when n % 2 == 1, always output "YES". For sequences with an even length n=2k, we already know that {a1, a2, a[2k-1]} can always be adjusted into {a[2k-1]', a[2k-1]', ..., a[2k-1]'}. To judge whether the whole sequence can be turned into a non-descending one, we only need to judge a[2k-1]' and a[2k]. To make it possible, we expect a[2k-1]' to be as small as possible and satisfy a[2k-1]' <= a[2k]. So the problem turns into finding the minimum a[2k-1]'. We can get the answer by traversing the sequence. Note the construction for the odd-length sequences is based on the last three consecutive elements in the sequence, we record the current minimum a[2k-1]' with $cur and take the next two elements into consideration, i.e, {$cur, a[i], a[i + 1]}. If $cur <= a[i], we can decrease a[i] to $cur and take a[i + 1]' = a[i + 1] + $cur — a[i] as the new $cur. Note the new $cur cannot be smaller in order to keep it non-descending. If $cur > a[i], we need to increase a[i] to $cur. Solution: 201627091.
I am still not familiar with interactive problems.
Why there are rating changes in div 1 but no rating changes in div 2?
why
why
why
Why?
why?
why?
why
Why
Why
why?
hwy
Why?
when?
@culver0412 Please look at the matter of div 2 rating update.[user:culver0421]
Why div.2 rating still haven't updated?It's not the normal speed,is it?
Why the rating of div 2 not updated yet, it has been done for div 1.
I hope the div2 rating update is just a delay, not only me but many people have worked hard in this contest
may be it is unrated
Any reason?
I will be deeply sad if a great round unrated,,,qwq
This round better be rated; it would make me blue.
Isn't it taking unusually long to update the ratings for the Div 2 contest? It's almost been 24 hours. culver0412 any updates?
I will ask my coordinator on what has happened.
Ok, thanks
Please update the ranking as soon as possible, sincere thanks
Feeling like Educational contest.
what happened???
Questions rating is updated but our rating is not update till now LOL.
May be Mike forgot about Div2 people (:
We should work hard to participate in Div 1 for a fast rating change ^^
LoL
Why the rating hasn't been updated? This seems unusual.
what's taking them so long, hope this contest stays rated
There is no reason for this contest to be unrated.
Can someone tell me what's wrong with my code 201696829 for D (Div 2.).
Read instructions for interactive problems. You should add cout.flush(); after all your cout’s.
won't "endl " do the same;
Sorry, yes it does. As far as I understood, you just restore the order of your permutation, however your tree is not 1-2-3…n and it is 1-n-2-… You should restore the indices by multiplying 2 permutations .
[]
HMMMM ill probably have grandchildren by the time they will update the ratings
I think they are waiting for their parents to decide their names :-}
As far as I know, the round is rated for both divisions. Please wait patiently, we have contacted our coordinator regarding rating changes (but we haven't received a response yet).
UPD: Ratings have been updated. Thanks for being patient. Although it would be better to not spam so many comments under this blog post as I have already clarified the situation.
When there is going to be a rating changes?
If I waited for my ex for this long I would be happy married with her rn
.
Please update the rating fast. I can't wait anymore :(
An Eternity has passed but the codeforces rating is still not updated.
There will be a maintainance soon, probably update after that.
I have some questions about the hack of each contest, why this submission can be accepted when running the following test, hope someone can explain my stupidity!
https://codeforces.net/contest/1816/submission/201550399
Input : 1 8 1000000000 1 1000000000 1 1000000000 1 1000000000 1
Where is the rating update?(
Why haven't the ratings been updated yet, even after the maintenance has got over, was this contest Unrated for div 2, culver0412,snowysecret
No reason to do that. Chill )
Maintenance is complete but it looks like this round won't be rated
would be really tragic if that happened
It's confirmed. Mike forgot about Div 2 people.
Maybe I'm missing something, but why didn't the rating of div 2 change?
........
I would be surprised if they are purposefully holding back the rating changes. No point in spamming the organizers; if anything, it will just slow down everything even more.
MikeMirzayanov, div 2 rating not yet updated. Please look into this.
is codeforces round 865 is rated or unrated ? if rated then when will update rating >
it is rated and they have updated so chill
thank you
Guys, stop panicking. Coordinators probably new about server maintence, so we dont get our detla yesterday. Now since codeforces is back little time has passed. Just be patient and wait
was it unrated for div 2?
Finally
Finally, the rating has been updated
Sorry to all the coordinators and everyone, we got panicked and wrote a lot of comments on the same, Thanks for updating the rating.