Привет, Codeforces!
В 31.01.2022 17:35 (Московское время) состоится Educational Codeforces Round 122 (рейтинговый для Div. 2).
Продолжается серия образовательных раундов в рамках инициативы Harbour.Space University! Подробности о сотрудничестве Harbour.Space University и Codeforces можно прочитать в посте.
Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.
Вам будет предложено 6 или 7 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.
Задачи вместе со мной придумывали и готовили Адилбек adedalic Далабаев, Владимир vovuh Петров, Иван BledDest Андросов и Максим Neon Мещеряков. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.
Удачи в раунде! Успешных решений!
UPD: Разбор опубликован.
Hoping for a great contest on Chinese New Year's Eve!
China use different calendar , interesting.
Yes,but we use both of them.
Lo*** ka china
Are you really ke jie playing go? Wow
i feel he is not kejie.he has no free time to play.
Maybe he is just a fan of Ke Jie.Ke is very famous in China.
In india we got another New Year on the day of festival 'HOLI'.
Jie baby,my jie baby
Happy New Year :)))) Vietnam 3 — 1 China
Hope this educational round completes without interruption.
Почему в телеграме неправильно указано время?
Good luck everyone!
Happy luner new year :3 hope this will be a good contest to say good bye this year :3
*lunar
Oh tks u :3 i dont even noice it :3
Good luck and high rating for everyone!
As a competitor in China, I'm quite happy to have something to do one New Year's Eve!
Hi, pls upvote I couldnt think of a smart comment this contest
Наконец-то я достоин своей аватарки
Hope for good luck.
Sad that last unrated educational round wasn't compensated with a rated one.
But hoping this one goes well, GL & HF.
Score distribution when?
Score distribution when?
It will be held on extended ICPC rules.
It's like div.3, contestants will be sorted by the number of solved problems,then penaltiesEither the questions were easy or I have been evolved from div 3, the contest was really confidence-boosting, thank you
Best of Luck everyone!!
May you not get WA at the very first problem. LOL
well.... :')
guess what happened.... I got one
Happy Chinese New Year!
Is this contest, a negative point is given to every wrong submission? Or it is the penalty-based contest?
10 min penalty for every incorrect submission until it gets accepted
penalty-based
This is gonna be my first division 2 contest after getting my first rating on a division 3 contest. Contest means full of excitement and inspiration to make me a better version of myself. And hacking phase is awesome and breathtaking. Smile!
Do you know why the problem rating information is not shown for recent rounds' problems? (Codeforces Round 767 (Div. 2) and later)
all awoo's contsts are great
I always think that is we should solve problems from top to bottom or bottom to top? As I see lots of coders start solving problems from 2 or 3 questions
As far as I know, out of all problems you solve finally, each minute you put a problem unsolved is counted as penalty.
So it is good to start with problems that take less time to solve.
yes, this is always optimal for educational and div 3 rounds which have same points for every problem.
while for normal div2 rounds you may solve B or C first(depends on which you are comfortable) as they can provide you more points if you solve them first
but still its not always the case that you will benefit every time. though i prefer to start from A
Hi. I am new here. Wish me luck !
good luck to ya :DD
Good Luck to all Coders ! ! ! awoo's contest are fantastic ! ! ! Never give up the CodeForces ! ! !
First time on joining any contest. I dont expect anything but to be better. Such a vibe
all chinese coder are giving a down vote it seems XD. happy new year to all chinese._|_
Happy Chinese New year!
chuxi forces :)
happy lunar new year to those that celebrate!
Why in Problem D, sample hasn't been explained. :( T_T
Omg, it took me 10 minutes to solve the problem A, and 8 minutes to solve problems B and C together, cool
It felt interesting to me, that in rated rounds I try to not even waste a single second, while you also take the time to announce your submit status xD.
I dont solve today's round on this acc
??? But it is still your time ???
This is even worse because you are publicly admitting to alts.
It's not mean, that I have alts, its mean that I'm sure my solutions are right
Lets be real, everyone has alts. I think its fine as long as people don't give rounds from both of them at a single time.
Not everyone has alts. I don't have an alt. And it's not fine if you smurf using your alt.
Problem E looks interesting but it also seems to 100 Kms above my interesting interval ;_;
it was my first round ever and thankfully to authors it was pretty fun. Thanks!
solution for D?
calculate the number of operations required to convert ai to bi and then knapsack.
Did same but got Memory Limit Exceeded on Test 12. Value of k given is much larger than 1000 * (maximum steps required for any ai to convert to bi). Took k as minimum of k and steps*1000 after contest. Got AC ;-;
There's a much tighter bound, use steps * 12. You can reach any number less than 1000 in less than or equal to 12 steps.
https://codeforces.me/contest/1633/submission/144748935 [TLE in test 12, problem D] How do i optimize the knapsack dp for choosing the indicies?
Observe that if k is greater than sum of all operations we can skip knapdsack dp. And sum won't be too big.
the maximum number of operation to obtain any number from 1 to 1000 using that operation is 12. So k can be at most 12*n. So if k > 12*n just make k = 12*n
Thanks Eren and Liviu, got AC. Feeling stupid right now!
Liviu how did you come up with "#ops to obtain any number 1 to 1000 using that operation is 12"?
just printed the maximum element after the calculation was done. I needed that number to be small enough in order to not get TLE.
In fact you can write another program to calculate this.
How can I calculate the number of steps required to convert ai to bi?
DP. You can calculate it for every number from 1 to 1000 cause b[i] <= 1000. Now you know that dp[1] = 0 cause a[1] = 1 already. And now make a for for each number 1 <= j <= i and let dp[i+i/j] = min(dp[i+i/j],dp[i]+1). This means take the minimum number of operation to reach the number (i+i/j) coming from i state (which is already calculated).
Ex. you know dp[1] = 0 dp[2] = 1 dp[3] = 2 dp[4] = 2 dp[5] = 3 and you want to calculate dp[6].
dp[6] = min(dp[3]+1,d[4]+1,dp[5]+1) since you can reach 6 for 3 adding 3/1 for 4 adding 4/2 and for 5 adding 5/3 or 5/4 or 5/5.
I used dynamic programming for D, can someone show me why it get WA? https://codeforces.me/contest/1633/submission/144729710
Your DP state is incorrect. Use 01 Knapsack DP : Link
I thought what I'm doing is 0-1 knapsack. I thought that looping in reverse order of the dp state (dp[i] = best total coins given total cost i), makes it so the element of the knapsack can't be re-used. Anyways thanks for the tip.
I compared with the guy who got #1 and saw that my dp state and recursion are exactly the same as his (144679861). After looking at the case I failed on, it's because of this code
Starting from i=1, instead of i=0, breaks for the case
because the optimal solution (take the second coin using zero operations) has zero cost.
My opinion about problem E.
For E, is this lemma correct?
O(m^2) distinct MSTs.
Care to try hacking my code? It should run in $$$O(m ^ 3 \log ^ 2(m) + k (n + \log(m)))$$$ if that is the case which should be too slow to pass, even in 4 seconds.
Any hints for E?
Lol!!! Have you hacked into the system ? I did the same complexity but still get TLE on Test 8, while your code ran in ~ 100ms. I even removed one log(m) factor by not sorting every time in binary search but just merged the negative weights and positive weights by their abs value. Still I am getting TLE. submission
I think I calculate optimal MSTs in a different manner from you I think. There is no case in any of the tests (including hacks) that has number of MSTs $$$> m$$$. So my solution actually runs in $$$O(m ^ 2 \log^2(m) + k(n + \log(m))$$$.
For example, on test 8, my code finds 252 ranges, your code finds 32000.
aryanc403, any ideas on how to generate a case with number of MSTs $$$> m$$$? I can't seem to either prove this idea or generate such a case.
Oh! Cool... Then it seems that about (m^2 — m) swappings of edges are unnecessary. i.e. They dont change anything in the spanning tree. I get that it should be definitely less than m^2 but only m msts are there. Interesting. Anyways thanks for the interesting result. It would be nice to see atleast some intutive proof from aryanc403 or someone.
Me neither. I tried hacking his soln but couldn't create a test case with more than O(m) MSTs for his soln.
Rn, I don't have any proof for O(m) upper_bound on MSTs.
Regarding intuition -
Lets's call MSTs $$$T_1,T_2,....,T_l$$$ as generated in ExplodingFreeze soln.
Let $$$e_j$$$ be an edge present in $$$T_i$$$ but not in $$$T_k$$$ where $$$i<k$$$, if we can somehow prove that $$$e_j$$$ would never be present in $$$T_{k+1},T_{k+2}, ... , T_{l}$$$, then we can easily prove O(m) upperbound on his soln.
It's similar to a sliding window, each edge is inserted only once and removed only once and is present in a specific subarray.
Probably proving it would be easier if we compare relative weights of edges in $$$T_i,T_k,T_{k+1}$$$, but I haven't tried it rigorously.
Hint for problem D
NHK bro?
k doesn't need to be 1e6
Can you tell me how did you derive that during contest?
if you try to calculate how many steps are needed to reach numbers 1 to 1000 (using simple dp) you will notice that there is an upper bound over these numbers (which is 12). So the maximum usable value of k would be 12*1000 and the rest is standard knapsack problem
For problem E which group of x should suffice to check? I tried all edges values and every (edge[i]+edje[j])/2 values but got WA
In problem D, Ceil(log2(bi)) is star I think because this many steps is required to change 1 to the particular number.It's just a theory based on 1 + (1/1) => 2 + (2/2) or 2 + (2/1) etc.. for each number.
No this fails for b[i] = 7
Video Solutions for A-D for anyone looking
D was a nice question. 0-1 Knapsack DP hidden behind a good observation — max operations on any index i can be atmax 12. So if k>=12*n, ans would be sum of array c otherwise apply standard DP for 0-1 knapsack.
Is it possible to get the cost to transform a number to b[i] using greedy?
something like,
Tried the same and got WA on 2nd test case. So, I'm assuming it will not work. BFS is the way, I think
I thought of BFS too but implemented array of sets approach along with DP. My submission https://codeforces.me/contest/1633/submission/144766502
problem d approach is as knapsack dp problem ?
someone pls help! https://codeforces.me/contest/1633/submission/144748512
Problem F is nice .
But I wrote the dfs order as index ,and debug for about 40 minute (how can this pass the first 12 tests ???).
And I found this silly mistake in the last 30 seconds ..
Share my solution here :
If you know a tree is perfect match . Then u has an edge to father[u] iff size of the subtree of u is odd .
When adding a node , you need to flip the parity in the path from u to 1 (root).
So you can use HLD and segment tree to maintain it .
But when the tree is perfect match ? In fact , when the number of nodes whose subtree size is odd is equal to $$$\frac{the\ number\ of\ nodes}{2} $$$ . Proof is easy .
Problem A is exact copy of this TOPCODER ROUND. Even the number 7 is same.
Solution for C ?
Notice that the sum of k<2*10^5.
That means the solution should be O(n).
To Check who wins- find number steps needed by both to win (that means if the character kept attacking how many rounds are needed to defeat the monster and vise-versa)
character_steps = ceil(monster_health/character_damage)
monster_steps = ceil(character_health/monster_damage)
if character_steps<=monster_steps then character wins (First chance is of character so <=) Checking who wins is o(1)
To find all possible combinations in the way we can use the coins- we can go from 1 to coins (i) and use
i
as the coins used for damage boost and usecoins-i
as the coins for health boost and add the boost to the damage and armor. We can do this in O(n)It seems that D can be passed in $$$\mathcal{O}(nk)$$$ time
Maybe it will be better if the time limit is changed to 1s ...
It's not actually $$$O(n\cdot k)$$$ where $$$k\approx 10^6$$$.
Since the number of operations needed for any $$$b_i$$$ to get constructed is at max $$$12$$$, if $$$k\ge 12\cdot n$$$, you can simply print $$$\sum_{i=1}^n c_i$$$. Otherwise you can use a knapsack dp solution so solve the problem in $$$O(n\cdot k)$$$ time where $$$k\lt 12\cdot n$$$.
why?, if k >= 12*n then we can take all coins?
If $$$k\ge 12\cdot n$$$, it is possible to make all $$$a_i$$$ equal to $$$b_i$$$. Hence we can collect the value $$$c_i$$$ for all $$$i$$$'s.
I mean i Know that but how, some example or proof/link?
Simply use DP to calculate that.
Compute the answer for each $$$1\le i\le 10^3$$$ and check for the maximum. It will come out to be $$$12$$$.
But in fact,some guys solved this problem in $$$O(n\times k)$$$ and I cannot hack them. Are there any stronger cases than this? QaQ
I can't open the link you gave, it says "access denied".
Can you provide me with such a solution?
Sorry,that is my problem.
This!
$$$n=1000,k=10^6,b_i=1,c_i=10^6$$$ cannot hack him. QaQ
Try this one: https://codeforces.me/contest/1633/submission/144717276
Actually the total number of operations is $$$\approx 10^9$$$, so it might be possible for a solution to pass under 2 second time constraint. Plus the operations done inside the test case loop are simple enough. The only thing that user needs to optimize is the space used which cannot be $$$O(n\cdot k)$$$.
I've tried making test cases with max constraint and the program runs perfectly within 2 second time limit.
DitaMirika,rsg23
Hey, you stole my comment! Just kidding.. =)
The time constraint is $$$2$$$ seconds by the way ))
Um, I hadn't read your comment until now actually.
Thanks fixed!
Yes I understand that, but what I want to express is you can pass this problem even if you use the 01-pack dp for every $$$k$$$ but not just when $$$k\le 12 * n$$$
How to solve E?
What is the hacking phase??
There might be some solutions which either shouldn't pass according to the given constraint or are actually wrong but the systems tests don't cover the cases where they fail.
Codeforces gives the users, an opportunity to identify such solutions and hack them (submit a valid test where they fail). Obviously it does not guarantee $$$100\%$$$ strength to the new test set formed after hacking.
I hacked my own solution for B rip.
Really nice contest.
Today is the day I will learn Knapsack, Thanks for the round
In problem D how do I find the number of operations for each number I tried to do it but got WA here is my code: https://ideone.com/Fm0aPE
I precompute them using BFS. Find the shortest path from 1 to all nodes
You can write a brute force dp for this. Just make sure you have an idea about dp solutions.
Consider $$$dp_i$$$ stands for the minimum number of operations required for making the number $$$i$$$ starting from $$$1$$$.
Then, it can be seen that before forming the number $$$i$$$, we might have had a number $$$j$$$ such that the value of $$$\lfloor \frac{j}{x} \rfloor$$$ was equal to $$$i-j$$$ for some $$$x$$$ (because that's the only way $$$j+\lfloor \frac{j}{x} \rfloor$$$ will become equal to $$$i$$$). Let's iterate on $$$j$$$ too. We will then need to find the value of $$$x$$$ (if it actually exists).
Basically, we want to find an $$$x$$$ such that $$$\lfloor \frac{j}{x} \rfloor=i-j$$$. Well, if there were such an $$$x$$$ possible, it would be the maximum $$$x$$$ such that $$$\frac{j}{x}\ge i-j$$$ (notice that the division is not integer division).
In other words the maximum integer $$$x$$$ such that $$$x\le \frac{j}{i-j}$$$ which is indeed $$$\lfloor \frac{j}{i-j} \rfloor$$$.
We only have got a possible answer. If this $$$x$$$ satisfies $$$j+\lfloor \frac{j}{x} \rfloor = i-j$$$, it means it's possible to reach $$$i$$$ from $$$j$$$ in a single step, hence $$$dp_i=min(dp_j+1,dp_i)$$$. If it doesn't satisfy the equation then just skip this $$$j$$$ and check for another.
I will understand and try this thanks.
In problem D , I assumed x should be a divisor of a[i] out of nowhere, and now I won't reach expert because of this.
Well it says ai / x floored (note the floor function brackets) which indicates that x doesn't necessarily divide ai.
Yeah, I read it initially, but while implementing missed it completely.
Same Here, but i figured it out after 1 hour and 3 wrong attempts :(
Same thing bro
Help needed in Problem D. This is my solution What I did was calculate operations for every b[i] and then select those with best (c[i]/operations) in decreasing order. But this gives WA. Any ideas why?
EDIT: The way I calculate minimum operations is probably wrong. I'll just wait for the editorial.
I think you answered your own question. You can't solve 0-1 knapsack with greedy.
I am actually taking the entire points and not just a fraction of it. I wrote greedy because I sorted the numbers in decreasing order based on their worth (points divided by operations) and selected them greedily. Maybe I should remove greedy knapsack from the comment if it is confusing.
What I am understanding from your comment and code is that you are trying to solve this knapsack which is impossible with greedy.
Never be greedy :p
c — 10, 4 operations — 2, 1 k = 1
according to you 10/2 is better than 4/1 but we cannot take 10/2 as limit is k=1.
I am checking for that as well, if operations are greater than what is allowed I skip it.
No the point is that you cannot solve the knapsack problem with a greedy approach. Take for example values — 3, 2, 2, 0 and cost — 2, 2, 2, 1 and capacity=4. If we take elements greedily, we will take the first element because 3/2 is more than 2/2. However, the optimal solution is to take the second and third element,so this approach fails.
I've wasted too much time and energy on D thinking b_i<=1e6. Sad
I like the idea of E but its implementation is way out of my skillset :(
Klog(m^2) passed for me with maps in 2000ms. Hack it, maybe? :p
I have a question, does an unsuccessful hacking attempt on Hacking phase gives us any penalty in some ways?
In Problem D, number of operations to convert 1 to x is
(index of MSB in x) + (number of set bits in x) - 1
No need of fancy math. run n*n bfs as {1,1}
{i, steps} -> {i + (i/j), steps + 1} for all 1<=j<=i
states = 10^3, TC: 10^6 bfs
No need for fancy BFS. Just run 2
for
loops =)How do you know this regularity?
Have u tried? I did the exact same thing first but got 2 WA. Then I switched to BFS.
I did this in contest and got wrong answer, brute force implementation after contest gave AC, are you sure this is correct? (maybe I implemented it wrong)
This isn't correct:
Try for 19: 10011
Index of msb: 4
setBits: 3
Your ans: 4+3-1=6
Actual answer: 5
How to reach: 1->2->4->8->16->19 [19 = 16 + 16/5] in total 5 steps
I did this mistake too.
15 = 1111 Here ans ≠ (3) + 4 — 1 = 6
But optimal soln is 5 (1->2->4->8->12->15)
Happy Chinese New Year for every Chinese!Hope all of you will get good grades in xcpc(icpc&ccpc) in this year!
What happened to rainboy??
Is standing broken?
Any hint for problem E?
I got WA on test 7, I mapped all queries, if a query occurs an odd number of times I sort all edges by abs(x — wi) and find MST with Kruskal's algorithm.
My code: https://codeforces.me/contest/1633/submission/144721913
E was too hard to code
When you get traumatized by interactive binary search problems xd
I didn't know 2 can be done with binary search.
E was too hard to code
In problem D, Why I am getting tle on testcase 12 https://codeforces.me/contest/1633/submission/144763541
$$$k = min(k, 12n)$$$
after considering this condition, still got TLE under python3 .... here is my code
BTW, I found another code, which was accepted during contest, but also TLE now...
really weird ....
codeforces.ml ? kinda sus
Actually you could solve it even without that optimization =)
I use the following justification:
1. Knapsack performs $$$k * n = 10^6 * 10^3 = 10^9$$$ operations.
2. CPU speed is 2.4Ghz or $$$2.4 * 10^9$$$ operations per second.
3. If we access the data properly, CPU will utilize it's fast cache and registers instead of waiting for data from RAM (RAM is 10 times slower than CPU cache).
4. We have 2 seconds limit on the problem, so we have some room for overhead computation and round trips to RAM.
144830143
By the way, I like the code that I got after incorporating the idea of short circuiting.
That is, we don't do $$$dp$$$ if $$$k$$$ is large enough.
This short circuiting allows us to reuse unoptimized code from above without using magic constants
k = min(k, 12 * k)
. Everything works out by itself and the code would work even if we have a different problem with larger constraints, so we don't need to recalculate new constant for12 * k
.144830112
same code, but different compiler, one gave wrong answer but one got accepted(after contest)
144765410 144698088
Anyone knows the reason ? Help will be appreciated :'(
Upd:My second submission also gave wrong answer later in main tests due to float, so I think
double >>>>>>>> float
It's because you are using float and float is not accurate, i had the same problem from few days my solution got accepted in c++ 17 but not in c++ 20 and someone told me why this happened you can check the reason float fail sometimes to give AC here
PS: changing float to double in your code give AC, so when u want a floating number next time use double!
thanks man !!
Can someone clarify this? In E when I used edges as vector of vectors , it gave TLE. In some AC submission I saw they have used structure for edges. When I used structure instead of vector, it passed. Why this behaviour?
I submitted with vector of vectors and it ran in TL. 144786518
I didn't know there is a space optimized version of solving KnapSack
Is O(NK + KlogK) the intended solution for E or is there something better? I am processing the queries in a sorted order and just updating the edges in the MST only when the sorted order of the edges changes in the next query. It is easy to see that the sorted order of the edges won't change more than M * M times.
You can use promo code
CountingSortUsingBitset
forO(logK)
off. You may need Find_Next as well.Thank you, how Find_Next may help?
for problem D, anyone succeed to get accepted by python3? why I always got TLE? here is my code
BTW, I found another code, which was accepted during contest, but also TLE now... weird ....
I was able to make it up until 8'th test with Python3: 144836343
Exactly the same code with PyPy 3.7 (64 bit) passes for 187ms 144836442
Probably the difference is in the input speed.
In Problem D test case
4 4
1 7 5 2
2 6 5 2
cant we make [1 1 1 1] -> [7 1 1 1] in 4 steps, as conversion from 1 to 7 takes 4 operation and then answers should be 6+2+2+2 = 12. Whats wrong here
Never Mind, Seems like I have completely misinterpretted the question
Problem E. There can be at max e*e event points where we need to re-calculate MST. giving e*e*e*log(n) as preprocessing time.
for given x we need to find y<=x in above event point list and do some calculations.
I did it with y = map.lowerbound(x) -> Gave TLE complexity O(k * log(e * e))
People did it with presorting x and using two pointer to get y for given x- TC: O(k * logk)
SInce log factor of sorting is better than log factor of map, hence i got tle.
I think problem shouldn't have such tight constraint that sorting pass but map.lower_bound() fails. What do you guys say?
You could presort y and lower_bound for every x query (without using two pointers and presorting x), map just has terrible constant factor.
Can someone tell why this method of finding the minimum number of operations to convert 1 to b[i] is wrong :-
This is what i've done — Im finding the nearest power of two (call this num) for b[i] and then convert num nearest power to b[i]. To do that first i find the difference between b[i] and num and update num greedily such that num + [num/x] <= b[i] till i get num == b[i].
This is the piece of code for finding this minimum number of operations.
Greedy doesn't work because you cannot make sure that by incrementing with the largest possible move will lead into minimum possible weight.
So apply dp here too (similar to coin change).
I usually don't write such stuff, but I must say I'm really disappointed with the pretests for problem C. For such a short mathy problem, You'd expect to give constraints in a way that don't give an overflow with a pretty standard solution. And if there is a standard solution that gets an overflow, it's only right to give a not-so-difficult-to-construct pretest that prevents it.
For educational rounds it's even more important to have strong pretests on the easier problems, due to the fact each problem weighs the same.
Thanks, a CM that instead of getting to master for the first time, gets a -95 :(
Yeah already got a contender for the worst problem of 2022.
Hey but let's rejoice we can just move ahead with int128 from here onwards and forget about these silly problems the setters come up with.
but longlong is enough here
Tbh, most of the times there is at least one problem with ridiculously high constraints in Edu rounds.Moreover, almost always the pretests are weak to encourage hacking. Maybe you have been just lucky to not get FSTed before.
I haven't seen that many problems with ridiculously high constraints (that can't be handled by long long) in Edu rounds. Can you give examples? Moreover, it sounds extremely weird to me that the pretests are weak to encourage hacking. After all, the purpose of the pretests is to validate solutions... But I agree that I might have been somewhat lucky to not get FSTed until now.
Yoav What do you mean by "You'd expect to give constraints in a way that don't give an overflow with a pretty standard solution"? Pretty standard solution here is to use long long and it got AC here
https://codeforces.me/contest/1633/submission/144683828
Look at my hacked solution. In my opinion my approach is quite standard, and is correct but gets an overflow. After checking again the constraints it is easy to see there can be an overflow. So if the constraints are made in a way that there could be such overflow, there should be pretests that cover it.
Good contest and interesting tasks !
Are editorials released?
Can someone please help me figure out why my solution for D isn't working? 144791596
In my opinion, 2 seconds TL on problem D was too much. It let some unoptimal solutions pass.
Yeah, I saw many O(n*k) solutions passing
Hey There!
Can someone please tell me what stress testing is and how to use it during the contests?
I received this suggestion from some revered person :"You can try stress-testing to find the test cases you're wrong at" I often apply the right logic in contests but end up with failing a few test cases.
Best, Wandering Brain
You can write naive solution (even exponential one), generate some small test cases and compare your solution against naive on those small cases. To make it efficient you should automate the process of generating random test cases and comparing your solutions.
I should have done problem C in python :( (Wrong Answer on testcase 13 due to Overflow)
Hello guys. I'm new in codeforces and this was my first contest. I solved one problem. Will my rating increase?
Yes
FSTforces :(
+100 delta to negative delta
Got FST on both C and D today.
If this had happened on Topcoder, it would not be unusual because TopCoder emphasizes on proving your solutions with your own edge cases as their questions are usually more about implementation (imho).
But this is certainly not what I used to expect from Codeforces rounds as the questions are usually more about coming up with the idea and being guided about whether that works or not with pretests.
what is FST?
Failed System Test.
fstqwq
I figured out that in D, knapsack was the way to go, since we can interpret that weights are no. of operations to reach each element. I found the required way to reach all elements in nlogn, and since N was <=10^3, thought knapsack would work, but k was <=10^6. I do not know how to lower this. any hint would be appreciated
Using DP on the number transitions, you could pre-compute the number of steps required for each of the numbers (1->1000), and because this was kind of logarithmic (max. 12 steps), you could effectively reduce 1e+6 to around 12000, which is manageable.
My Submission (has FSTed)
thank you, I'll try again. Why wasn't this came in my head earlier
The maximum operations required to obtain any b will be logarithm in nature so the actual max value of $$$k$$$ will be $$$nlogn $$$. Hence, the problem becomes knapsack DP with complexity of $$$n*n*logn$$$. Check out my solution, it did not FST
144759233
Weak pretest for problem C :(
I suddenly realize that in Educational Rounds solving ABD with more penalty time will be ranked lower than solving ABC with less penalty time. So, in such rounds instead of solving harder problems it's important to guarantee the solved easier problems are correct.
I initially "solved" ABCD but just got FST on C which makes me feel sad. (C makes me realize "long long overflow in C++". Perhaps I should use Python 3 for all such large integer problems.)
C gave another chance to Python users to mock CPP users ;-;
IMO, This is one of the worst contests ever. Felt like the tasks as well as the test was created just as a formality. Please don't create this type of contest.
Can't disagree with you, I always highly rate the educational round but this one was far below standard.
I'm down-voting this contest and this post , because of weak testcases for problem C and problem D , that causes me negative delta! From ~2800 to ~8000 ! This content damaged my rating a lot. But actually the problems were interesting.Thanks.
Couldn't agree more! Weakforces
I dunno know why you were downvoted. If the pretests are gonna be this weak they might as well not include them at all and leave participants to make submissions on a gamble.
Weak test cases for D!!Even an O(nk) solution passed.
144799151 Problem C, my solution is failing on TC 13. Can anyone please point out what's wrong?
144799151 Problem C, my submission is failing on TC 13. Can anyone please point out what's wrong?
Its overflowing when you do the operation $$$(attacks - 1)*dm$$$ . Very weak testcases this time
Pretests for Problem C were very weak, I had an overflow in my code and it passed, if pretests were strong then I would've gotten a WA but usually codeforces tells us if we have an overflow and I'd have been able to AC.
Two Contests back : I might become CM Now : Specialist , I am coming
Can someone please explain why this submission for D is failing test case 21?
The Submission
Thanks.
To not keep you waiting, the ratings are updated preliminarily. In a few hours/days, I will remove cheaters and update the ratings again!
Down with codeforces From now on weakforces
Chill dude, it was just one mediocre contest with weak pretests.
Can you make a post when this testing is done as well?
Is there any update? Are the ratings updated?
The test data in question C makes the variable overflow of "long long" in some incorrect writing, which is nicely designed
'Nicely Designed' can be either sincere or sarcastic based on the result, lol.
Can anyone explain why the remaining queries in problem E are defined by the modular arithmetic formula instead of straightaway giving them? Edit : Seems like it was because the number of queries is very large my bad
I got accepted in A, B and E. But I FSTed in C, D.
New year, New FST, New -189, New Candidate Master -> Expert.
Take it easy, Maybe it's the Pillar of a future success.
Still better than falling 400 rating into pupil from high expert over the course of several contests.
From now, I will check overflows even after using long long. :(
In D, I got a TLE just because I created a new function to calculate my ans. Can anyone explain how does that work?
For your D just apply a check that if k >= 12 * n print the sum of all c[i]. Because at max it would take 12 operations to convert 1 to b[i].
You don't need to go for k = 1e6. Your AC code for D runs in 1996ms, after applying the check it runs in 15ms.
ok, thanks a lot!
gone from positive delta of 160 to negative delta of 20....XD. D got hacked and C failed in system tests due to overflow. I hope to improve in next round
my 3rd contest ever C failed in test 10 after showing accepted whole night . could have reached 1k rating now stuck at 898 only.\
python solution with same logic now shows accepted.
This was my first round in Codeforces, and I am going to share my ideas while solving the problem A and B.
1a. Problem A — O(1) idea
during the contest phase, I did not come up with the idea to change the last digit only (which was, I think, the expected solution). Instead I focused on the fact that the input is 3 digits maximum, and the divisor is 7. 1 (mod 7) = 1, 10 (mod 7) = 3, 100 (mod 7) = 2. Therefore I thought it would be possible to make up every difference in 0~6 with these 3 digits. However I decided that this is not the correct solution as it would be impossible to find all the cases in 2 hours for me.
1b. Problem A — BFS idea ( O(27^steps)? ) (My final solution)
This time I found that the input is only of the two cases, TWO DIGITS or THREE DIGITS. I thought BFS would finish relatively early. (This speculation turned out to be correct, and it all ended in one step.) So I did a BFS on changing each digit to 0~9 (non-leading digits) or 1~9 (leading digit), and the runtime was only 15ms. Sounds good enough to me.
2a. Problem B — O(n^3) idea
I only had this idea for a very brief amount of time, and I knew this idea would always TLE out on even the weakest cases. and you probably guessed what it is. Yes, the good old "counting every substring we could find". Good thing I didn't have to try this.
2b. Problem B — O(n) idea
I really hesitated on this idea, and I could not easily prove that this would always work. I did focus on the fact that we have to maximize the amount, and later on it turned out to be the correct approach but I had the suspicion of DOES THIS REALLY WORK for probably 20 minutes or so. It's the classic answer of (cnt0==cnt1)?cnt0-1:min(cnt0,cnt1) where cnt0 and cnt1 is the amount of 0's and 1's after counting the whole string. I submitted the answer as a gamble to myself, and I am still amused that this turned out to be the correct answer.
So yes, this is a list of my ideas in my first Codeforces round. I really hope I have a better performance next round or so, but I would really appreciate learning new ideas from Educational Rounds and Div.3/Div.4 Rounds.
In educational codeforces rounds, I personally think that each problem should be given points as given in other Div2 and Div1 contests. Because if some person was not able to solve C due to some small error but was able to solve E. Still, he/she will be having less rating than others because time taken to solve E was more than C.
Solved E => +90
FSTed D => -70
Happens..
Happy new Chinese year!
Happy new Chinese year!
Problem D was so simple yet so tricky at the same time :) Great Problem
When will the official editorial be released ?
for Problem B Minority, if input is 1100 then the output according to answer is 1, but since both number of 0's and 1's are same, so the output should be 0. If it is 1, can someone please explain how?
Consider the substring "110". In this substring we can remove '0'. So ans is 1.
Auto comment: topic has been updated by awoo (previous revision, new revision, compare).
Can anyone help me, why I am getting run time error in Problem E 144915859
Finally solved 3 problems!