Thanks for participating!
Tutorial
Submission
Tutorial
Submission
Tutorial
Submission
Tutorial
Submission
Tutorial
Submission
Tutorial
Submission
2066D1 - Club of Young Aircraft Builders (easy version)
Tutorial
Submission
2066D2 - Club of Young Aircraft Builders (hard version)
Tutorial
Submission
Tutorial
Submission
Tutorial
Submission
thank you for the quick editorial, questions were tricky.
I need to understand official approach, hoping to get some proofs of correctness
Idea for B — Two Large Bags
Now
re-consider
this problem with the following idea:For each number
i
in the array,count[i]
should be even. You are allowed to perform operations on the counts. The allowed operation is :if count[i] >= 2
, then you can performOperation:
count[i + 1]++
andcount[i]--
.Key Idea
Even Pairing Requirement: Each number
i
must ultimately appear an even number of times so that the numbers can be split equally between the two bags.Pushing Numbers Forward:
If
count[i] > 2
, one might think to push allcount[i] - 1
copies toi + 1
. However, there is a catch:If you push
count[i] - 1
numbers, then there will be only 1 copy ofi
left, meaningi
will not be paired with any otheri
. Therefore, you only need to pushcount[i] - 2
copies toi + 1
, leaving behind a pair ofi
.Greedy Approach:
You have to carry these extra numbers as far forward as possible because they can combine with any upcoming larger number and form a pair with that number. TC :
O(n)
SC :O(n)
.Yea I did a similar approach, just keep pushing numbers forward leaving 2 at the current number. When we reach a number where the freq == 1, the answer is "no" since it can't be split equally. When we reach the biggest initial number, just check if it's frequency is even, since every number before will either have a freq of 0 or 2.
What is wrong in my comment, why you people are downvoting it?
Just consider it good comment then, people here are kinda weird.
Yeah, Thank you man!
Thanks for your approach!
good contest , bad contest
I reached CM!
The best contest i've ever particpated!
True
Reason?
Bro become CM after this contest
His rating exceeded 1900
please make editorial for problem D in English
How was it supposed to be deduced for A that 'n' is supposed to be a 'positive integer' only? The problem specified for 'n' to be an 'integer' which allows a larger set of valid pairs. More precisely for each currently accepted (x, y), (y, x) should also be a valid pair.
Or am I missing some detail?
oh yeah, correct, it says integer
There was an announcement stating that n is positive. Apart from that, there is nothing that says n should be positive.
oh man ,
many people who were solving it assuming negative and missed the announcement because they were looking at their notebook might have spent so much extra time.
Ok thanks, I fortunately read the announcement before submitting. It was just that the announcement seemed to imply that the fact was deducible from the problem statement itself, therefore I was confirming.
tricky but insteresting questions!
sevlll777 Problem D (Div2) or Problem A (Div1)'s Editorial is in Russian language only.. Please make it available in English !!
It is translated on Polygon. I guess some time is needed to pull it up from here, should be available soon
Interesting and exciting.Love it!
FST.
Is there a problem in the interactor of Div. 1 A (Div. 2 D) Object Identification? This submission 305637703 passes the sample locally but gets WA 1.
we are investigating it
I'd like to mention that I looked for format error for about 20 min due to the misleading information from the bugged interactor in this submission and the lack of interacting process for the sample.
Can anybody explain why this doesnt work for A?
There will be cases where $$$y\pmod{9} = 0$$$ and your code would check if $$$x\pmod{9}=-1$$$, when it should be checking if $$$x\pmod{9} = 8$$$. You can replace your code with
and it should work. Also you aren't printing a new line, which you should.
Really helpful! Thanks
why did u add +8 ??
-1 mod 9 is 8 mod 9
Ohh ....I see. Thank you
x=1,y=2; test case is failling. Consider num=100,num+1=101 then x=1 and y=2
It passes pretest 1 bro
See you have a integer number n let say it consist ABCDEF where A,B..F are digits
Thing about the two case:
Case 1: Where unit digit (here F belongs to [0,8]) n+1 make it belongs to [1,9] that mean the whole structure of number n would remains constant except the unit digit F so the sum would increase just by one x = A+B+C+D+E+F y = x + 1
Case 2: Where unit digit of n is 9 now n+1 will make unit digit 0 and carry 1 will be forward to E, again thing of two case E belongs to [0,8] or E == 9, if case 1 then simply it will add up 1 and stop other wise make digit E = 0 for n+1 and forward that carry to D.
so you got a sum x for n, for n+1 you are going to get some zeroes in place contiguous 9 from unit place (let say k no of 0 replacing k 9's) and finally adding 1 to very first non 9 digit.
so y = x- k.9 + 1
clearly visible (x + 1- y) must be divisible by 9 by taking care that (...) is >= 0.
That's it.... I hope it is helpful and easy to understand pardon my bad English
Appreciate your explanation. Thanks!
Here's a combinatorial solution for D1.
Let the number of planes launched from $$$i^{\text{th}}$$$ floor be $$$u_i$$$, note that $$$u_{n} = c$$$.
Now corresponding to this case in the original dp recursion solution we get the term $$$\prod_{i=1}^{n-1} \binom{c}{u_i}$$$
So the final answer is just sum over this expresion as $$$u_i$$$ ranges over all possible values constrained by $$$0\le u_i \le c$$$ and $$$\sum_{i=1}^{n-1} u_i = m-c$$$.
Now this is equivalent to a counting problem where we have $$$c(n-1)$$$ distinct objects divided into $$$n-1$$$ types with $$$c$$$ objects of every type and we want to choose a total of $$$m-c$$$ objects. The above expression occurs when we count by first deciding number of objects of each type and then choosing the objects per type. Instead we can directly choose the $$$m-c$$$ objects.
Hence the answer is
Version without needing to know the DP:
Choose the throw order for the top $$$k$$$ floors.
For the floor below, you get $$$c$$$ choices of either throwing your plane or letting a plane fall from above.
This happens for all floors except the top floor (which must throw $$$c$$$ planes).
So in total there are $$$c\cdot(n-1)$$$ choices, and $$$m-c$$$ must be chosen to actually throw planes, thus $$$\binom{c(n-1)}{m-c}$$$.
B was a really good problem. I wasn't able to submit the right code in time, however I still enjoyed taking my time solving the problem.
its awsome, Like your previous competitions, this one also had a lot of mathematics!
div1A >> div1B
Rating roll back when ? I want to be expert in problem solving
just curious, who or what is Devyatkino, and how is it related to the 2067C problem?
Devyat' = Nine in Russian
Problem D was really interesting theory-wise, pretty cool for an interactive problem to actually be accessible for regular users rather than being 2300+ rated
A YouTube solution got leaked in the last 10 minutes of Problem E. I don't know much of Div. 1 but in Div. 2 more than 10 people in top 20 have been cheated having the same solution and it might get worse lower down in the standings. Some of the solutions are with comments and exactly same, I don't know how they escaped plagiarism but something needs to be done about these cheaters or else the fun of competitive programming will end soon.
Yeah completely agreed, Here I try my best to increase my rating and on other side my friend has higher rating because he is cheating.
In C, if n = 6, answer is actually 9, not 8, right?
6+9*8=78
Solved ABC and had some idea about D. The problems were interesting and the observations were not very obvious. Overall a nice contest.
After regrading, my submission to Div. 1 A now says "Wrong answer on pretest 4." If my rating is going to be calculated based on this, this feels unfair, since it would not be hard for me to fix my solution to the problem, if I knew this was the verdict. Also, it seems that some people had the opposite problem, where their solutions failed in contest but were correct. I think the correct decision here is to void the contest.
"It is not difficult to understand that it is optimal to take the leftmost zero in the subsequence" for problem Div2 E why taking left most zero is optimal..?Can anyone explain in detail?
You only need to consider the leftmost 0 for two reasons:
1) You only need to check the condition until the zero you chose to keep in the subsequence. Everything after that will be valid (min = 0 and mx = 0), so you want to have the 0 as soon as possible.
2) Checking until the index of the first zero is similar whichever the 0 you decided to choose, so based on the first point you want to check the smallest part possible.
Consider for example the sequence 2 0 1 0 1, checking the first element is independant of the zero you chose to keep and if you decide to keep the second zero the condition fails on it (mn = 1, mex = 2)
sevlll777 Could you please tell the testcase where some of the rejudged solutions of Div 1.(A) have failed. Specifically testcase 37 on pretest 2.
testcase 37 on pretest 2 is:
Thanks
Is there a way to solve the second problem using the frequency array?
305680148
Yes, of course here is how i solved it in the contest , do check it out bro. you take a frequency array and then check if it appears more than twice , redistribute the excess counts to the next number by increment operation. after that check if all frequencies are even then only it is possible.
I understand it now, Thank you very much bro
can someone please help me why my bfs code did not work
in problem c
In problem A of div1, if you use fast read in to read in, and your solution happens to be wrong, when you read -1, you'll get TLE on test 2 for not having end-of-line spaces and line breaks (at least in my tests, I think). In fact, for this reason, I kept thinking yesterday that it was cin/cout that was too slow and wasted almost 45 minutes. I don't know if this problem is present in other interaction problems, but I think it has a big impact on players who are experiencing this problem for the first time, and I think the interactive library should give the correct verdict on the procedure according to the rules. I hope this issue will be revised in the next time.
I'd say it's quite a bad habit to use fast I/O method on CF. The only method to avoid such issues is to stop using fast I/O as far as I know.
In which cases your code gets -1? queries seems fine
Can someone please tell me how did they derive this "(x-y + 1)%9 == 0" formula....I am new please help********
Suppose any number whose last digit is not 9 can have its immediate next number +1 with the last digit thus the first part : x+1==y
Now the other case if there are 9s at the end of n. Let 1199 then n+1 will be 1200. Here x = 1+1+9+9 and y = 1+2 so (x-y+1) means 1+1+9+9-(1+2)+1 = 9+9. You can see that for numbers which have any number of consequitive 9s at the end the next number's sum of digits will be its sum of digit + 1 minus those consequitive 9s. Thus if (x+1-y)mod9 is 0 it means that we can form n with consequitive 9s at the back. so if it satisfies the this condition x and y are valid.
Thanks brother
Can anyone explain me how the case of last digit is solved for in Problem C.
1E is a classic trick in CNOI.
I think 1E is easier than 1C in CNOI.
in C you said you cant explain it briefly! this is the contest for making people to get new ideas , to have fun , to learn new techniques, not for searching the random idea in your head which you cannot even explain briefly. Do you believe you explanation is worth it? CF is being a joke day by day just for problem setters like you who came here to show how cool are they not to set cool problems
Have you read editorial through the end? It's not like I dont explain ideas, it is just a choice of words to justify (or motivate) idea of adding $$$10^x$$$ instead of $$$99.99$$$ in the operations, since it is easier to see how digits are affected in this case. I could just directly explain solution instead, but I believe explaining motivation behind some ideas is also important, and thats what Im trying to do usually, [side note:however I would agree that in D2E solution is not well-motivated, the thought of looking at zeros is pretty random, but] I believe D2C explained well, if not please tell me what is unclear...
How would you solve the problem using bfs?
In problem 2067D - Object Identification, why is one query insufficient in the second case (when $$$x_1,x_2,…,x_n$$$ is a permutation)?
Is there a case in which one query will give a response $$$>=$$$ $$$n - 1$$$ and the other will not?
Can you provide a counter-example for the one-query approach? thank you :)
something like
Path in graph theoretically can have length of $$$n-1$$$ if it goes through all vertices of the graph ($$$1 \to 2 \to 3$$$ in this case), and if $$$y_i = y_j$$$, Manhattan distance can be also equal to $$$n-1$$$.
that's right, thanks!! I thought that the distance between nodes are measured by nodes count not edges count :)
B. Two Large Bags
The editorial code outputs "No".But, is this case should be "Yes"?
update: it's the same content, not sum.....i'm stupid
Quit trolling bro. No cool.
Some thoughts on 2E / 1B. What if we consider the weighted version of this problem? I mean, let every $$$a_i$$$ have weight $$$w_i$$$, and now we need to find not the maximal possible length of a magical subsequence, but the maximal sum of weights in a magical subsequence.
Such version of this problem looks very curious for me. Now we can not just say that the subsequence without zeroes outperforms almost every other subsequence, and we need to go deeper. Seems i have a solution for this version, and it looks really nice (but, ofk, it also might be wrong :) ).
Did anyone have some thoughts like this?
Hmm, yes, my "solution" was wrong indeed) But the problem statement still looks curious!
Tutorial for 2067E — White Magic: "(this can be easily done in O(n), calculating prefix-min and suffix-mex is a well-known problem)".
I know how to calculate suffix-mex in O(nlogn), but I didn't know it can be calculated in O(n). What is the idea behind faster solution?
Ignore elements that are bigger than $$$n$$$ since they are not impacting any suffix mex. and just use counting array for elements $$$\leq n$$$. You can refer to code from submission from editorial.
Thanks.
The interactor of div1 A seems to have some bugs.I got TLE on the sample but that's impossible.
Question about 2067F Bitwise Slides:
1) When x=pref(i-1): There are a total of 3 ways to arrive from (pref(i-1),pref(i-1),pref(i-1)).
2) When x is whatever: We can come from (x,x,pref(i-1)) to (x,x,pref(i)).
Aren't 2) when x=pref(i-1) and third way from 1) duplicates? How can we be sure that we aren't counting the same operation twice?
1E can be solved with 1 log, i.e. $$$O((n+q)\log (a_i))$$$
Submission: 306294227
And it's also easier to implement compared with the official segment tree + binary search approach.
FYI (helped with AI translation)
Solution
Noticing that Operation 1 is only useful when two barrels contain the same weight of water (otherwise the presence of poison won't affect the result), and the barrels selected in Operation 2 must be confirmed poison-free.
Initially, we must select two barrels with $$$k$$$ kg of water each and compare them. If poisoned, the process ends. We consider the case where their weights remain equal (i.e., no poison exists).
At this point, the freely disposable water quantity is $$$2k$$$, denoted as $$$L$$$.
All operations can be categorized into two types:
Starting with $$$L = 0$$$, the initial process of finding two barrels with $$$k$$$ kg can be described using Operation 2. Therefore, we discard the first step and solve the problem starting from $$$L = 0$$$ with no confirmed barrels. If we can confirm $$$\ge n-1$$$ barrels as poison-free, output
Yes
(the last barrel can be determined by elimination).We accelerate this process using range doubling decomposition.
Divide the value range into $$$O(\log a_i)$$$ blocks of $$$[2^k, 2^{k+1})$$$.
A key property emerges: if any barrel in a block is confirmed poison-free, we can confirm the entire block.
Proof:
For a barrel $$$a_i$$$ in block $$$[2^k, 2^{k+1})$$$:
For each block $$$[2^k, 2^{k+1})$$$, maintain two
multiset
to track:Traverse blocks from smallest to largest. If a block contains a confirmable barrel:
A block $$$S$$$ is confirmable if and only if:
The first condition is easy to check by maintaining the minimum value of each block.
The second condition requires checking:
which can be done in $$$O(1)$$$.
Thus, the time complexity is $$$O(n\log a_i)$$$. (because we only traverse each block once)
Maintain the sum of confirmed blocks and count of confirmed barrels to determine the final answer.
There is another solution with the same complexity
Use a segment tree
On position $$$i$$$ maintain the value $$$pref_i - i$$$ where $$$pref_i$$$ is the sum of elements of $$$a$$$ that you can have if you currently have value i. Now we can't get to the $$$x$$$ if
min(0, x)
$$$ < 0$$$.Now look at each pair $$$(a_{i-1}, a_i)$$$ (in sorted array). If you have access to the value $$$a_i - a_{i-1}$$$ then you have access to the value $$$a_i$$$, so you can do
add(a[i]-a[i-1], a[i])
. You can easily maintain this troughout queries usingmultiset
.One more thing, you can see, for example, that this doesn't work for
2 2 4 11 100
, because with2 2 4
we think we can get11
because $$$11-4=7 \leq 8$$$ but we can't use4
twice.To avoid this do the following:
If $$$2a_{i-1} < a_i$$$, do
add(a[i], a[i])
Else do
add(a[i]-a[i-1], a[i])
.305735628
so difficult
Solution for 2067B - Two Large Bags Using Frequency Counts
Create a frequency array to count the occurrences of each number.
If a number appears more than twice, transfer the excess to the next number.
If any number has an odd frequency, print "No".
If all frequencies are even, print "Yes".
Time Complexity: O(n) using frequency counts, making it faster than the sorting-based O(n*log(n)) solution in the tutorial.
Code Implementation: 307574956