Привет, Codeforces!
Мы с SomethingNew рады пригласить вас на Codeforces Round 814 (Div. 1) и Codeforces Round 814 (Div. 2), которые пройдут во 16.08.2022 17:35 (Московское время). У обоих дивизионов будет по 6 задач и 2 часа на их решение.
Мы хотим выразить благодарность:
- 74TrAkToR за отличную координацию раунда и идею одной из задач для Div. 2.
- pakhomovee за идею и подготовку одной из задач для Div. 1, а также за тестирование остальных задач раунда.
- Um_nik, 244mhq, turmax, fedoseev.timofey, errorgorn, FairyWinx, daubi, arbuzick, AlesyaIvanova, Dart-Xeyter, Alexdat2000, Vladithur, rafaelka, plagues, LeoRiether, satyam343, ilya.kligunov, 1024mb, 127.0.0.1, efimovpaul, Prokhor08, marzipan, kirill.kligunov, MirMak, dmitry.lisitsyn, MichsSS, PUFL, bpaT_Kapaca, RomkaRS за тестирование раунда и полезный фидбэк.
- MikeMirzayanov за системы Codeforces и Polygon.
- ilaburkov за то, что он существует.
Разбалловка:
Div. 2: 500 — 1000 — 1250 — (1250 — 1000) — 2500 — 2500
Div. 1: (500 — 500) — 1250 — 1250 — 2250 — 2250 — 2750
Мы надеемся, что вам понравится решать наши задачи!
Разбор
Поздравляем победителей!
Div. 2:
Div. 1:
As an author, I authored this round.
Good
I hope problem statements will be as short as announcement
As a contestant, i will contest.
As a participant, I will participate in this round.
As a tester, I tested this round.
It was a joke .. Anyways I have edited it now.
Bro dont do these type of things honesty is important
He already seems to be very honest.
Behind every joke there is some truth
.
Bro Just check my profile and you will get to know how honest I am. Secondly,never ever make false statement on someone untill you are confirmed about something.
wow !
As a Vladithur orzler, I will participate.
I am a participant if and only if I am a participant.
As a participant
ok
Aur mujhe bolta tha comment kyu padh rha :/
Hope I won't participate in another Speedforces round.
i hope so too
hopeforces
Is this round, a speedforces round?
spoilerforces moment
lol
question toh laga nhi rha, bas comment kara lo iss se
++
penaltyforces
true
I hope the questions are very difficult, so that I can show my strength. Ordinary div2 questions are too easy, and I type too slowly to get high scores. I hope it is more difficult!
^^ If a protagonist with "the power of friendship" had a CF account
you can start solving problem D , Have a nice Day
Good luck
Is there going to be some limitation with regards to rating? I'm a newbie can I still participate?
Everyone can participate in every contest. The only issue is that if your rating is too high, your rating will not be affected by participating in lower-difficulty (higher Division number) contests. But since you're grey, your rating will be affected by all contests. In fact, if your performance is better than what is expected of your low newbie rating, you will very likely have your rating increased. I highly recommend participating in ALL contests.
Respect for ilaburkov
“Thank ilaburkov for existing”……
Hope . I'll reach pupil this time.
I hope i can reach pupil,in sah allah
i hope , i can reach pupil in sah allah
i hope , i can reach pupil
I WANT TO REACH MAAAAAAAAASTER!!!!!!!!!
ok
Why do I feel that this announcement is quite shorter than others? In my impression the announcement of a contest is usually one screen long. (curious)
Really hope there is gonna be nothing wrong with this contest
Request to Authors : Please write editorial with hints and write hints themselves divided like Hint1, Hint2....
Request for Authors: Please write the editorial with hints.
Hope, I will get SomethingNew from this contest.
Became Green :)
Hope I will get some more brain after this contest.
glebustim
Hope my brain gets bigger after this contest.
-1024mb Brain Memory Limit
As a tester, i think that it will be a little bit hard round, but still, problems are great and not viscous
Hope to achieve a satisfactory result in this competition
Hope to get specialist back (again)
I hope to get expert on this round!!!
Me too! I got specialist today, and hope I'll get Expert after this round
I am newbie since long and now pupil :)
Why is it that every time I say "I will get Expert today", I lose a bunch of rating
Hope I'll reach Expert after this round.
i feel this round will be special <3
Hope I will see SomethingNew in this contest on my IP address 127.0.0.1 and won't be having glebustim to solve a problem that would have a memory limit of 1024mb.
you're so cringe kid
LOL, I usually try to do SomethingNew.
How about Wrong_answer_on_pretest2 ?
nightmare
Problem D in Div2 and Problem A in Div1 both have subtasks so does this mean that Div1A=Div2D? Will this Div1 be harder than usual?
Either that or an extremely easy one, I'm hoping for the latter to allow me to get close to 2100 mark again after AK in Div2. :D
I don't think sharing true info would be fair though, as some participants may opt to do/skip round if the answer favors them.
Yes, Div1 A is Div2 D. We think that this will make our round more balanced.
OK, thanks for your reply :)
so scared~ this could be my first DIV1 solving only A.....
as a tester, I tested this round
ilaburkov orz
As a tester, I tested this round. Good luck everyone :)
тяночку бы
Edit: I was wrong D:
Is this contest became unrated??
Hope to solve D this time :D
This will be my first div 1 Wish me good luck!
Hope to get pupil on this round ಥ_ಥ
lol
Interesting scoring distribution observation: In Div 2, the second part of the split problem is easier than the first part, but in Div 1, they’re apparently equally difficult…
I'm quite sure the Div2D = Div1A exactly. I doubt there is much to be gleaned from the discrepancy in how the scores are distributed. The Hard version is treated like a Div1A problem (which oranges/reds should be able to solve), with the Easy version being worth exactly half. But for Div2 participants, it's treated as a D problem, which isn't as accessible, especially since ABC would take up some time at first, so it's a little harder to achieve the Hard solution for this Div2D. I guess that may justify giving it slightly more score than the Easy version in Div2, despite being identical to Div1A, and I don't think anything could be inferred by the relative difficulty of the two subtasks beyond the estimate that they're roughly equal.
Make me closer to red, plz.
A1,A2 ?! Really rare!Hope that the round will be nice to everyone. :)
Only 50 points left to reach specialist. Wish us good luck!
me too
As an coder, we will code this round.
All The Best EveryOne !!!
Kindly remove the candidate masters from div 2 registered participants.
Why Burenka and Tonya? Where are Alice and Bob?༼ つ ◕_◕ ༽つ
Descriptions are there to help participants understand, not to prevent them from understanding.
Praise to Allah for the fact that I did not participate in the competition, if I participated in this contest, I, like many, would not be able to solve the problem C.
you know, my rating is not 1200
Once again praise be to Allah
speedforces, penaltyforces, gapforces.
Can't agree more
How to solve D1 and D2?
Also what's solution to B? I did some case work which is probably not intended.
Problem B: For k%2==1, just take (1,2), (3,4)... (n-1,n) For k%4==2 again take (1,2), (3,4).... ,but for pair (i,i+1) if (i+1)%4==0, take (i,i+1) else take (i+1,i) For k%4==2 there is no solution
Detail B solution is: look at n%4 and k%4. Then look at pairs mod 4: for example n%4==0, so numbers%4= 1, 2, 3, 0, 1, 2, 3, 0. If k=0 its impossible, k=1: a=3, b=1 and a=2, b=0 — 2 pairs. (so 1st pair a%4=4-k%4, second pair b%4=0)
First of all, lets do k %= 4. If k == 0 there is no answer, idk why.
You can solve this problem from each group of 4 independently:
1000 2
And so on...
Now just some case-work for each k value
Btw, i got B 10 seconds before contest ended (01:59:50 Pretests passed [pretests])
I didn't have time to implement it, but I think D1 can be done using 2D DP.
The key observation is that there is never any benefit to selecting a range of more than 2 elements, since the time taken for a block of size k + 2 is the same as the time taken for doing the block of k and the block of 2 separately. So to zero out an element whose current value is $$$v$$$, you would have to XOR it with $$$v$$$, but you can also choose to drag the next element to be XOR'd with $$$v$$$ (without costing additional time). There is no point in considering a longer range for this XOR.
For an array of size $$$n$$$, consider the last element. You can either zero out the first $$$n - 1$$$ elements (DP) and then zero out the last element by itself, OR you can zero out the first $$$k$$$ elements, and then start an XOR chain from the $$$k + 1$$$-th element, where each element becomes 0 while XORing its next element as well. Depending on where you start the chain, the residue at the end varies, so you can check all possible values of $$$k$$$ to determine which of these XOR chains will zero out the last element and then choose the one with the shortest time.
This takes $$$O(n^2)$$$ time, so it obviously wouldn't work with D2, for which I have no clue whatsoever.
the trick is to maintain all possible residue values in a set, and then use it if it lets u merge the next guy with the next block.
You can do this maintain by having a set and an additional "change" value that is supposed to modify all the elements of the set. To xor everything in the set, u just xor the change value, and to insert/query x, you insert/query x^change instead.
Doesn't the set get really really big?
u do it iteratively, like u only zero out the current block, and then consider pushing it one further (which adds/changes the residues). and if u can use a residue to merge a single guy with the next block u use it. So set only grows to O(n)
Ah gotcha.
Tried this, TLEd
Hmm, I just submitted this approach right now and it was accepted (only 124ms): https://codeforces.net/contest/1719/submission/168605232
I checked your submission, but I'm not too familiar with Java. However, it doesn't seem like you're actually a building a 2D array/table of the resulting XOR residues? So I'm guessing that you might be calculating the result of the XOR chain every time, which would yield a worst-case complexity of $$$O(n^3)$$$ (need to calculate the best time at a linear number of endpoints, each endpoint considering a linear number of XOR chains, with each XOR chain being computed in linear time).
But if you maintained a table of the residues from each starting point (can be 1D, now that I think about it), then it should reduce to $$$O(n^2)$$$, which should definitely pass.
Ah, you are right. I was in n^3.
Submitted an n^2 solution and passed, keeping a 1d array.
Problem B solution:
For k%4==0 we have that (a+0)*b=0(mod 4) => a*b=0(mod 4), so if a is odd than we have that b must be divisible by 4(we have n/2 odd nubmers from 1 to n and n/4 numbers divisible by 4 from 1 to n), so we have that for k%4==0 there is no solution.
For k%4==1 we have that (a+1)*b=0(mod 4) we can see that we can just print pairs that contains one even and one odd number(like {1,2},{3,4}, etc.)(same approach is for k%4==3(k%2==1))
For k%4==2 (a+2)*b=0(mod 4) than we can split all odd numbers from 1 to n in 2 groups. First group is 1,3,5,7,n/2-1 and the second one is n/2+1,n/2+3,...,n-1. Odd numbers from first group is gonna be first numbers of pairs(a) and the second numbers of that pairs(b) will be numbers that are divisible by 4(than we have pairs like {1,4},{2,8}, etc.). In other half of our pairs second group of odd numbers is second number(b) and the first number(a) is the numbers that gives rest 2 divided by 4.
nichke u can see my approach here
I DID NOT CHOOOKE!!!
upd: nvm i overcomplicated
Just guessed B looking at samples :)
same i guessed a and b
thats true however, its easy to verify the validation of the solution by bruteforcing the solutions however, i feel like the test cases are too weak i forgot to use long long instead of int when calculating ((a + k) * b) % 4 would it pass? ps : never mind i also made k long long ( however a and b is int) thats too an accident ( what a good accident)!
Was the round really balanced? I feel D1C is very easy and D1A2 (and A1) are crazy hard (almost I missed it).
at least you didn't lose your mind optimizing the wrong solution for C lol
idk, D1A1/A2 are quite simple with one observation, I missed A2 only because of i<=n in place of i<n in my code which gave me undefined behaviour :(
What observation is there in D1A1/A2?
you only need to xor segments of lenght either 1 or 2 (so when you find a sequence with xor 0, you can erase it for a cost = its length — 1, and you need to maximize such sequences)
Nice observation!
it's optimal to consider ranges which have their xor = 0 (i.e. xor(l,r)=0), cause you can always make them all 0 in (r-l) moves. Now just use as many ranges as possible, the rest you can make 0 in 1 move for each element
Example:
1 3 7 5 5 5 7 6
You can xor ranges: [0,1], [1,2], [2,3], so range [0,3] becomes full 0,
Then you can xor [4,5], so this range becomes 0
Then xor [6,6] [7,7]
You can't have more optimal solution for this case, and in general it worked for all cases, so the rest is only implementation details.
At least for A1 I can tell precisely, it worked. If you're still curious, what I did:
A DP[N][N] where dp[l][r] means number of steps to make range l,r 0. It works in n^2, which fits A1 restrictions
then i did another dp, ans[i]=min(ans[j]+dp[j][i]), j<i. Answer will be ans[n].
yeah, it got AC
code:
https://codeforces.net/contest/1719/submission/168606064
I mean, A might have been a bit tricky (maybe too tricky for an A), but crazy hard is definitely an exaggeration
why
I spent an hour trying to optimise 1C, then I realised you dont need to try all k = factors, just k = n/prime factor! Also, how do you prove that greedy works for 1B?
I'm just the same as you. And I solve 1C in 1h51m, and don't have time to implement 1B. Haha
sum of alternating fib numbers is bounded by the next fib. So if u have multiple things > the biggest fib, then not taking the biggest letter u have means that there will not be enough space to use it.
waiting for tutorial ...
div2 C , bet most of you all (who WA'd) got the approach right but missed some corner cases :D
Insn't it just simulate n fights and collect the wins foreach fighter? What edgecase?
lol, i got 6 WAs just because i forgot to print max(0, res) for player with power n
Ok, the strongest fighter is the edgecase :)
There's a test in the example for this edgecase though
what corner cases?
For those id=1 and id>1, the answer is different.
So, one corner case, I guess it's ok
My problem was that I forgot in some cases that there are k round, not infinite, and so I only managed to get AC on 6th try
In Div2C I did simulation of the first $$$n-1$$$ fights while answering queries. I sorted the queries by $$$k$$$.
same
OMG Is that work? I thought I must print the answer immediately after the query, So I use stack to find the Next Greater Element. My implementation is too complicated.
As an alternative we can collect the numbers of the rounds for the winners, and do binary search on each query.
https://codeforces.net/contest/1180/problem/C and div2 C are very similar problems
How to solve div2 D1? I tried to use dp but failed.
It is indeed DP. First it's easy to see that one either changes a[i] to i^x or changes a[i] to a[i]^x and a[i+1] to a[i+1]^x. So let's say that dp[i][j] stands for the minimum cost of changing the first i-1 elements to 0, and the i-th element becomes j. You can try to read my submission if you want: https://codeforces.net/contest/1719/submission/168590571
very clean and easy-readable solution, ty!
Always do operation on a subarray of size 2. Go from left to right and maintain all possible values current element can have. If any one of them is zero then pass otherwise one more operation.
I used hashmap :(( RIP, hack is gonna be BRUTAL. At least I can do D1 tho
I tried as never and fail as ever
Problem E is a kind of Graph Isomorphism Problem, with many restrictions on the graph. And my solution is, ahem, to run a heuristic solution to the general case (+ a bit of optimization).
in my opinion Div1: A1<B=C<A2<(a little bit)D=F<E
didn't have time to code F due to my stuck on A2
nice order
I thought that B >>>>> A = C and that having subtasks in A was completely pointless, so your order is very surprising.
I think the author should give more meaningful sample. My program that have so many wrong place can still accept the sample in problem A and B. But I don't think giving contestant meaningless sample should be the difficulty of the problem.
How to solve E in something like $$$O(nm\log(nm))$$$?
I found an $$$O(nm\min\{n,m\})$$$ solution which unfortunately cannot pass:
You are checking if two bipartite graphs, with edges colored, are isomorphic;
For each component of the bipartite graph, if you sort all edges by their color, choose a starting vertex on the smaller side, then DFS would give a unique sequence that determine this component. But in my solution I have to iterate the starting vertex, thus ends up with $$$O(nm\min\{n,m\})$$$ complexity. Just do this to both graphs and check if they are the same.
I had $$$O(nm \min(n,m))$$$ which passed the tests in 670ms, I think it was the intended or they would increase limits to make ti TLE. However, Um_nik managed to get it in 140ms. Maybe he found a better solution?
I guess hashing paths of length at most $$$O(\min\{n,m\})$$$ starting from each vertex is correct? If so, this would decrease constant by a lot.
I don't think I did that. I just hashed the entire grid.
Edit: It seems they decided to change the constraints of the output format to be annoying (it used to be $$$2 \cdot 10^6$$$) and now the above code is WA....
My submission: 168607716
I guess they added some tests after it was 140 ms, but it is still reasonably fast. $$$O(nm \min(n, m))$$$ too, no hashing, if you match one pair of vertices, there is at most one way to match their connected components, just run two parallel dfses.
Added
And it now passes in 1400ms
Sad, I wrote div2F a minute before the end. Fixed the bug 2 minutes after the end.
Thanks for the good question.
Why this solution of problem Div2.C get WA2 ?? I test it against thousands of random test cases but I didn't find the Wrong answer.
Expected : 0 Your output : 2
I don't understand where my solution is going wrong for problem Div2. C.
Submission : 168591816
Solution : Let $$$cnt$$$ be the number of rounds before the $$$i$$$th player, $$$cnt = max(0, i - 2)$$$then, if $$$cnt \ge k$$$, then, the $$$i$$$th player cannot play. Otherwise, subtract $$$cnt$$$ from $$$k$$$, so, now we have the maximum number of rounds the $$$i$$$th player could win, $$$k' = k - cnt$$$. If the $$$a_{i} = n$$$, then, we win all remaining rounds, else, if the prefix has some $$$j$$$, such that $$$a_{j} > a_{i}$$$, then, $$$i$$$th player can never win, otherwise, the suffix must have some $$$j$$$ such that $$$a_{j} > a_{i}$$$, the maximum we can get is the next greater element, which yields an answer $$$1 + min(k - 1, j - i - 1)$$$.
Please help me if I have made any wrong statement or I have misunderstood something.
if i=1,print 0+min(k,j-i-1)
I think one reason why the author hasn't put tutorial out is that he is strengthening the tests of F. $$$O(nC \sqrt q)$$$ passes pretests. Amazing.
edit: It's actually $$$O(qC \log \log C)$$$, which is still not the intended time complexity.
code
Fun fact: you can use bitsets to get a smaller total number of operations.
Fun fact: It passes main test. Victory of adventurer, haha.
ok maybe I misunderstood the meaning of 'adventurer', if 'the brave'?
I believe if you analyze my algorithm carefully, it is $$$O(q C log(log(C)))$$$, still too slow of course (somebody uphacked me), but closer to passing than you might think. I was aware that it could be too slow, but roughly quadratic for $$$10^5$$$ is worth a shot.
Yes I know the analysis, but I wouldn't have a try because I trust the author would be responsible for the task. I admire your courage to write the code with little chance to pass, but I don't think any responsible author would make such a mistake.
When writing the code I thought my code had a better complexity than it actually has. 5 minutes before the end I saw that the complexity was actually pretty bad. I submitted anyway, because it is only a penalty of -50, and the reward is way higher.
Edit: I thought you also got a -50 penalty when getting WA on a problem you didn't solve. Turns out I am wrong.
For Problem C in Div2, Can someone point out the mistake in the below logic.
Created an array — For each index , stored the next highest no's index
For each query,
No of rounds missed = max(0, i-2)
Reduce k with the missed rounds (k = k — No of rounds missed)
Then,
min( highestNoIndexOnRight-i-1 , k)
)(My submission — 168599929 — WA on Pretest 2)
what if k has become negative try to output max(0,Math.min( highestNoIndexOnRight-I-1 , K));
Dammn! An Indian rainboy!
Chad...
This score distribution sucks. I solved 3 problems, but got as much points as those who solved only 2, cuz of wrong submissions on B and C. If it was ICPC-ruled, I'd had penalty = infinity, but still would be higher cuz solved more problems...
How many participants are aware that, unlike Berland, Buryatia is not a fictional land? :)
Can anyone explain why does 5000 * 5000 is giving MLE in D1 ??
C was nice one... applied maxtillnow and nextgreater still got WA
Is it necessary to use monotonic stack in C?
me either, i just wanna know why it doesn't work and how to solve this problem.
Hi,
For anyone that solved Div1C/Div2F, how do you prove that checking all cycles of length $$$\frac{n}{p}$$$ for prime $$$p$$$ is sufficient? I was setting $$$p$$$ as all factors of $$$n$$$ instead, and spent most of the contest optimising something that wasn't even intended...
Thanks!
Imagine you have $$$\frac{n}{pq}$$$. This means you are collected $$$pq$$$ thing. Let's label them $$$1,2,\ldots,pq$$$ from left to right. If we used $$$\frac{n}{p}$$$ instead, we would collected $$$1,q+1,2q+1,\ldots$$$ or $$$2,q+2,2q+2,\ldots$$$ etc. etc. instead.
The mean of the (mean of each smaller sequence) is equal to the mean of the original sequence. Therefore, at least one of the sequences has a mean that is greater than or equal to the original sequence.
Another way to think about it is to think about why they banned jumping with a distance of $$$n$$$.
好疲惫啊,有点乏力
居然还能打中文
Test cases for C Div.2 were really weak, because O(n*q) will pass.
In every query, you can take for from 0 to index of given number to check if there is bigger number than given.
How to solve D1A2?
Transform [l, r] into (r — l + 1) / 2 segment with length of 1 or 2 unit.
An array of size $$$n$$$ can be cleared in time $$$n$$$ by simply applying the operation on each element one at a time, or by applying the operation on two elements at a time (first and second, then second and third, then third and fourth, etc), until one element remains for one more final operation. The nice thing about the time being exactly equal to the size (no additions or constant factors) is that the total time is unchanged even if we partition the array into any number of subarrays of any length and apply the procedure separately on each subarray.
The only way to actually save time is if there is a subarray for which the XOR of its elements in equal to 0. Then when we apply the operation on two elements at a time, the last remaining element will be 0, so we don't need to perform the final operation. Thus, we save one time unit for each such disjoint subarray, irrespective of the locations or sizes of these time-saving subarrays.
How do we find these time-saving subarrays? We can maintain an running XOR of the elements, and record each result. If our running XOR is $$$r$$$ before entering a time-saving subarray, then the result after we see the last element of this subarray is $$$r \oplus (\text{XOR of subarray}) = r \oplus 0 = r$$$. So when we see a residue again, then we know that we found a time-saving subarray. We don't care about when this subarray begins; only that it saves us one time unit. Our time-saving subarrays need to be disjoint though, so we need to reset $$$r$$$ after this.
tl;dr — Declare a residue set and initialize the residue to 0. Read through the values, applying the XOR operation to our residue. If the result is not in our residue set, then insert it. Otherwise, increment a counter, clear the set, and reset the residue to 0, and continue.
My submission: https://codeforces.net/contest/1719/submission/168615233
Check out my Div.2 C solution without queues, dequeues or vectors:
https://codeforces.net/contest/1719/submission/168582562
Div2 C test cases could have been better tbh, you just covered 2 cases where a[i] == n (we win everytime after max(0, i — 1) games) and where i is higher than the position of n (answer is 0)
C like C was good problem, but test cases are too weak.
Once you realise that A has to do with the parity of n and m, the kind authors have already provided the answers for all cases of odd and even in the samples. Thanks sirs!
Why this naive Mo's algorithm can pass system test of Div.1 F? I think simply place the primes one by one can hack it.
https://codeforces.net/contest/1718/submission/168599096
Maybe the problem setters didn't think about such a dumb approach. So they didn't have good tests for it.
seems like they haven't any good tests for whole set
After 21 months of perseverance, I finally became an expert. After countless frustrated and frustrated nights, my hard work has paid off. I will keep trying to be a CM and never give up. Bless all those who struggle.
For me, my solution for div1B is a total mystery. I have no idea how an apparent backtracking could pass in 233 ms. However, the problems were not very interesting and, combined with some overthinking it was catastrophical. Hope to see some better div1 A and B problems in the future:))
Hello stranger!
Hello stranger!
Ratings updated preliminarily. We will remove cheaters and update the ratings again soon!
bad and strange tests in Div1B
during contests I had submitted $$$O(k^2\log k)$$$ solution per test, it passed pretests in 800ms
I resubmitted faster version before end of contest paying 130 places
After systest original submit have passed tests in 1300 ms (!!!)
I tried to hack it with exterimely stupid test and it was successful 168605608
So, wtf is tests in this task?
I would argue that setting $$$t$$$ large with $$$n$$$ really small is just bad practice in general -- with such small values of $$$n$$$ it often happens that constant optimization matters more than complexity and as such it becomes really hard to intuit if your solution will pass in time or not.
Adding a n<45 check to your code makes it pass reasonably comfortably for the stupid test, at least: 168630258
Okay i think problem C should have had more points assigned to it compared to problem B. In my opinion problem B was easier, i got baited by the point values.
I spent a lot of time on Div2E thinking that there is max flow or min cost max flow solution but i did not figured out how to use it. Sad :(
Quick review for D1 ABC:
A: Answer = n — (max # of disjoint intervals that has xor sum zero). A fair problem.
B: First check if sum(a) is sum of Fib numbers. Then brute force where Fib(n), ..., Fib(0) comes from. I never know why backtracking runs so fast.
C: For each divisor d of n s.t. $$$n/d$$$ is a prime, use a segtree/multiset to maintain $$$\max_{0\leq i < d}\sum_{k} a_{kd+i}$$$. There are at most 7 such d-s. Therefore, it won't TLE. Quite a standard problem.
can someone help me figure out what's wrong in my code for problem Div2-B and what is the possible test case it is failing. https://codeforces.net/contest/1719/submission/168580820
Try n = 2 and k = 1
Question C was hard to implement
d2E is among the worst problems I have ever seen on this platform
In problem A of Div2, please explain how Tonya wins in the testcase "2 2". I don't understand that.
Burenka is at (1,1) so she can either go to (1,2) or (2,1). From both cases Tonya plays chip at (2,2) , since it is the corner, there isn't any more place to go for Burenka.
I didn't get it. Burenka starts at (1,1), then lets say she moves to (1, 2) after than its Tonya's turn. He starts at (1, 1) and lets say he moves to (2,1). Now Burenka's turn, she moves to (2, 2), which is the only possible cell. Now it's Tonya's turn but he can't go to any cell according to the conditions in the problem. Thus Burenka wins. Where am I wrong here?
it seems like you misread the statement tonya will start from the index where burenka left and then burenka start from the index tonya will left and so on
They are moving the chip , not moving themselves
A fun fact about Div2 A: the outcome does not depend on the players' moves.
Hint. The parity of the Manhattan distance to the destination alternates between moves, and a move is always possible when that distance is odd.
i have tried out every single test case i feel like but i dont know where am i going wrong. can anyone pls look into it. https://codeforces.net/contest/1719/submission/168625241
1
2 1
2 1
1 2
2
3
168630508 (Take a look at checker's comment for second pretest)
editorial?
DIV2 (ABCDEF)video Editorial for Chinese :
Bilibili
When will we be expecting the tutorials? I struggled on question D1, could someone shed some light on the problem?
First, observe that there is no benefit to applying the operation on a range of more than 2 elements, since it doesn't save any time compared to applying the operation multiple times (on ranges of size 1 and 2 only).
Applying the operation on one element at a time will cost $$$n$$$ time units. Applying the operation on two elements can guarantee zeroing one element, but we'd then need to include the other in the next operation. We can perform this kind of pairwise sequence of operations until one element remains, which we apply a final operation to. This also costs $$$n$$$ time units.
How do we save time? If there is a subarray of $$$k$$$ elements such that XORing all elements results in 0, then we can perform the pairwise sequence of operations on this subarray. The one element that remains must be 0 after this, so we can skip the final operation and spend only $$$k - 1$$$ time. This generalization also includes the case of $$$k = 1$$$ (if an element is initially 0, we need 0 operations to zero it).
DP solution (works for D1): For an array of $$$n$$$ elements, if there is a suffix of say $$$k$$$ elements whose XOR is 0, then we can apply the optimal solution (through DP) on the first $$$n - k$$$ elements and then start a XOR chain for the last $$$k$$$ elements. We would, however, need to try all values of $$$k$$$ to find which suffixes XOR to 0, and pick the one with least time. Even if the suffix does not XOR to 0, we need to store the result, so that we can quickly extend the chain to a new element (instead of recalculating the XOR chain). My approach defined $$$dp[i][j]$$$ as the result of the XOR being applied from index $$$i$$$ to index $$$j$$$: https://codeforces.net/contest/1719/submission/168605232
This has $$$O(n^2)$$$ runtime, so it won't work in D2. A 1D table should work too (since it's only the different starting points we care about), but I didn't bother refining this further and it would still take $$$O(n^2)$$$ runtime.
Counting solution (works in both D1 and D2): Actually simpler than DP, but you need the additional observation that the locations and sizes of the time-saving subarrays (where the elements in the subarray XOR to 0) are completely irrelevant. Each time-saving subarray saves one time unit regardless, so the optimal time is simply $$$n$$$ minus the maximum number of disjoint time-saving subarrays. We can detect a time-saving subarray by maintaining a running XOR and inserting the results in a set. If we receive the same result twice, i.e., $$$r \oplus a_i \oplus a_{i + 1} \oplus \cdots a_{i + k} = r$$$, then the subarray $$$[a_i, \ldots, a_{i + k}]$$$ XORs to 0 and saves time. We don't need to know when this subarray starts; we just need to detect when it ends, allowing us to increment our saving counter and reset the XOR chain. You can check out how simple it is here: https://codeforces.net/contest/1719/submission/168640804
Andalus, can you please explain What it actually means by " disjoint subarrays with XOR of 0 " . Actually a little bit confused in understanding that. For example on array :(in case you want to know) 1 3 2 1 2 3 1 ,
I kind of got stuck on this.
Note that $$$1 \oplus 2 \oplus 3 = 0$$$. So for the array $$$[1, 3, 2, 1, 2, 3, 1]$$$, the subarrays $$$[1, 3, 2]$$$ (first three elements), $$$[1, 2, 3]$$$ (fourth to sixth elements) and $$$[2, 3, 1]$$$ (last three elements) all satisfy the property that the XOR of the elements is 0. Let's denote this as a 0-XOR subarray.
So for example, we can zero out the first three elements in two operations as follows: $$$[1, 3, 2, 1, 2, 3, 1] \to [1 \oplus 1, 3 \oplus 1, 2, 1, 2, 3, 1] = [0, 2, 2, 1, 2, 3, 1]$$$
$$$[0, 2, 2, 1, 2, 3, 1] \to [0, 2 \oplus 2, 2 \oplus 2, 1, 2, 3, 1] = [0, 0, 0, 1, 2, 3, 1]$$$
In general, if you have a 0-XOR subarray of $$$k$$$ elements, then this subarray can be zero'd out in $$$k - 1$$$ operations. So we can partition our original array as $$$[(1, 3, 2), (1, 2, 3), 1]$$$, where the brackets represent 0-XOR subarrays. So it takes two operations to zero out $$$(1, 3, 2)$$$, two operations to zero out $$$(1, 2, 3)$$$, and then there is a $$$1$$$ remaining that needs one operation (number of operations to zero out elements outside the 0-XOR subarrays is equal to the number of such elements), for a total of 5 operations.
Alternatively, you could also partition the array as $$$[(1, 3, 2), 1, (2, 3, 1)]$$$, which also requires 5 operations. There are actually three 0-XOR subarrays in the original array, but two of them overlap, so we can only exploit at most two of them, hence the need to count the maximum number of disjoint 0-XOR subarrays.
In any case, since we can have two disjoint 0-XOR subarrays from an array with seven elements, the output should be $$$7 - 2 = 5$$$, regardless of the size and location of these 0-XOR subarrays.
Why does Tonya win if the case is: 1 5? Cant Burenka just move 5 to the right and Tonya cannot do anything?
Can someone please tell me why a specialist won the div 2 round? Did the guy purposely create a new smurf account?
This is only their fifth contest, with their first contest being in July 31st, so it's very likely that they're simply new to Codeforces but are actually really skilled and experienced in CP (through numerous other mediums). So even though they start as grey, they would perform far above what's expected of their current rating, (getting a significant boost from each contest) until they reach the rating that more accurately reflects their skill level, at which point it would be more stable.
While it's unfortunate that someone who might be Div 1 tier is rated in Div 2, the reality is that we won't know that they're Div 1 tier until they prove themselves through these very same contests that they would dominate in. If they really are Div 1 tier though, it shouldn't take long for them to reach a more accurate rating.
fifth? That's not true. It is only their second. Also, out of the top 5 in div 2, only one of them (TasselFlower in 3rd place) has actually competed in more than five contests. I don't see why so many people who are so good at competitive programming will only just be joining Codeforces given how big of a platform it is. It only makes sense for me to think that they either cheated (which I don't think so) or that they have created new accounts
Sorry, I mistook who you were referring to. I do think there are many outside Codeforces who are so good in competitive programming, due to the numerous other alternative mediums. In fact, I myself used to train through weekly offline contests at university, and I would prefer that over Codeforces if it was still an option for me now.
I think the use of alt accounts to participate in contests below your actual level would still qualify as cheating, but in any case, I don't think there's any evidence that suggests that whether it's an alt, a cheater, or someone new to CF. But unless it's a cheater, they should quickly jump up to the appropriate rating and this should no longer be an issue.
The recent contests are so wrong. There's a huge gap between C and D
Not really. Look at LightBrand's solution of D1 and D2 above. It is quite simple apart from the fact that you have to make some key observations.
I resubmitted my code of problem div1c several times after the contest, which has got a TLE(above 3000ms) on the system test, but it passed all the tests in below 2800ms each time ...(including system tests)
I think the efficiency of the judging machine has fluctuates too much.
submissions:
TLE,during the contest: 168600537
AC,after the contest: 168640013
Is it possible to rejudge my submission?
MikeMirzayanov
Why are there so many downvotes :(
Problem D1 and D2 is my favourite
When will the editorial be published?
bro what
I am a newbie,where can I find the tutorial of this contest?
It usually appears in announcements, but it hasn't been published yet…
What does "Unexpected verdict" mean in hacks?
Now I'm uphacking solutions of Div2E/Div1B and I used the data generated by:
But I received the verdict "Unexpected Verdict". What does it mean? Does it mean that the authors' code can't pass this test so it's unable to judge or something? If anyone has seen verdicts same as mine please give me an explanation, thanks :)
When I set $$$T=1$$$ it shows "Unsuccessful Hacking Attempt" but why when $$$T=10000$$$ I receive "Unexpected Verdict"? So is it reasonable for me to doubt that the authors' code gets TLE on this test?
I think it's reasonable for you to suspect that the authors' code gets TLE'd on this test. I think hacks are judged by first validating that it satisfies input constraints, then running them on the authors' solution to generate the correct answer, before running them on the hack target's code. But if the authors' solution itself doesn't pass (due to TLE, MLE, or anything other than "Wrong Answer"), then it would make sense to consider this as an Unexpected Verdict.
I don't know for sure whether this is the case here, but it does sound like the most plausible explanation (especially with how tight the limits are).
I don't think this affects the Unexpected Verdict, but your code contains an signed integer overflow, because the 50'th fibonacci number is too big to fit into an int.
Oops, I just wrote a simplified version of my code in the comment so I didn't notice that, sorry. But my original code uses long long which gets the same result. Also I only used the first 43 fibonacci numbers (which is actually $$$\le 10^9$$$) so int is enough for them.
UPD: I'm sorry I checked on other compilers and the answer seem to be correct.
I tried both of these in the Custom Invocation (https://codeforces.net/contest/1719/customtest) and the correct answer seems to be printed in both cases. I think the issue is from the medium that you're trying these tests on. Are you sure you're using a C++20 compiler and not some older version?
I'm using c++21. Thank you for correcting me though
Randboy`s code outputs 4 on both of your test on my laptop...
Видно что русские составляли :)
Can anybody help me find a testcase for Div.2 C where my code(168707975) fails? I tried to use all the ones posted here and they seem to work. I've simulated n-1 fights till the n comes to the first position, storing indices where a number wins and loses.
Expected : 1
Your output : 0
Hi, I got a message from the system saying that my solution is similar to that of another user. However, this is because we both use the same template which can be found at https://github.com/JaroPaska/competitive_cpp_17 and was published before the competition.
A good round