Привет, Codeforces!
Благодаря поддержке Neapolis University Pafos, продолжается серия образовательных раундов. Университет предлагает получение степени бакалавра в области компьютерных наук и искусственного интеллекта со стипендиями JetBrains. Получите передовые навыки в области искусственного интеллекта и машинного обучения, которые подготовят вас к востребованным техническим карьерам. Любопытно? Присоединяйтесь к прямой трансляции во вторник, 29 октября в 17:00 UTC, чтобы узнать о программе CSAI, ее учебном плане, структуре курсов, стипендиях, стажировках для студентов и практическом подходе к обучению.
Хотите получить больше опыта в программировании и математических соревнованиях?
JetBrains Youth Challenge возвращается в ноябре 2024 года!
Кто может участвовать?
Возраст 13–18 лет.
Все, кто в настоящее время обучается в средней школе.
Зарегистрируйтесь сейчас.
В 28.10.2024 17:35 (Московское время) состоится Educational Codeforces Round 171 (Rated for Div. 2).
Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.
Вам будет предложено 6 или 7 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.
Задачи вместе со мной придумывали и готовили Адилбек adedalic Далабаев, Иван BledDest Андросов и Максим Neon Мещеряков. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.
Удачи в раунде! Успешных решений!
UPD: Разбор опубликован
qp
dp
pp
qq
bd
cp
gg
cf
tk
Haha, I broke your silly chain.
NO you didn't
LL
As a participant, I hope everyone participates and outperforms themselves in this contest.
I got a question, the penalty of time i.e. 10 minutes is the format of div. 3 and it is in this contest which is div. 2 so will the hacks have -ve points on unsuccessful attempts?
No, hacks are done after contest ends so there is no penalty
but it is written 12 hours hacking phase
12 hours after the contest ends
glhf
If I get minus again in this contest,I will leave CP.
Did you know that 95% of people leave codeforces before their biggest delta ever?
That's why I am still CPing after getting $$$-35$$$ and $$$-8$$$ in a row. (Got $$$+4$$$ is the last contest :))
I am still going to give this contest although got -102 :( in last contest
-140 and -54 in a row :(, for me
means, +250 is waiting for you, only if you practice hard.
only -43? lol
lol. I solved $$$1$$$ problem and got $$$-253$$$ in a contest CF1930
Thanks. You guys motivated me.
Edit: Motivation overloaded :). Lost $$$37$$$ in the last round (Solved only one question which is worse than my first ever contest in CF)
100% actually, even tourist
CP is not for rating just telling you, be better you will be higher rated. Its a hard skill, keep practicing.
Don't leave! I'll touch your acc and help you.
help me also!!
Are you planning to leave CP too? :(
-
Yes, I need your help! :((
Can confirm, wltt touching my account helped me
Please guide me as well what should i do to improve i tried different approaches but It has become a cycel positive delta in few contests and then a biggest -130 or something, and this loop continues for a long time, Please guide me your what can i do looking at my current situation ?
-59 in the last 3 contests 😎
-297 in the last 4 contests xD
take a rest/leave when it's no longer feels good. Comeback when you feel it or just leave it be.
Will I leave CP cause I am sure that I will get minus... I solved 0 problem...
Take a break
Leave CF. Go to LC and atc spend 3 months solving mediums and A-D (on atc) there, and when you come to CF stop solving 800-1000, push yourself, gl
meow meow meow meow (what i was made for tune)
i didn't solve a single question in this Edu round, I'm easily having -150 in this contest.
I haven't lately been able to see any of the other users' submissions. Everything I see is "N/A" for source code, even for problems I have solved. Any solution to this very annoying issue? Thanks!
same for me, could you solve the problem??
Could anyone tell me what means CP?
Today is my debut contest with Rainboy strategy , gonna start from $$$D$$$
get ready for -250 XD jk bro all the best hope u do best
hmm.. brave-kid ohhh ok!
It's extended ICPC rules, it's not beneficial to do this.
beneficial if you can make sure that you will solve it and if it is a points giving contest.
I am not caring about rating for now, for now my goal is to get full grasp of $$$D$$$ as soon as possible so that I can become yellow fast
nice I am also gonna use it now in today's codechef
at least u did it, nice try xD I'm also doing it.
As a contestant, I wish to test the problems live
Doing contest, problem B feels weird AF so imma skip it. Please correct me if it's skill issue.
It's too standard problem, Just Binary Search the possible values of K, Solve more problems and you will find that it's a very common standard problem.
Binary search is possible but not necessary. This can be solved in O(n)
Yes but it a standard binary search problem, The O(n) solution will be hard to implement and we don't need this at all,
Á đù hội anh em KHTN.
Figured that the O(N) solution would be just "stitching" a[i-1] and a[i+1] together for every i and check, right?
KHTN
elaborate please
Can you please tell how to solve it in O(n)
O(N) solution for (B): 288645656 I refuse to elaborate, I hate (B).
I solved it with prefixes in and I think its pretty clear O(n) 288565752
N is only 2000 so i was tired with it and decided to go "Fk it" and yolo with O(N^2).
> inb4 "O(N) exist", I know but I'm too tired with B and I just want to get over with it.
$$$A$$$ is hard ._.
"black circles" flashbacks... 2002C - Black Circles
I was able to solve black circle pretty fast that time this one was hard for div2 A
I learned my lesson after failing black circles.
Do guessing sometimes, trade off between a penalty vs a quick solve + spare time for other problems.
u know what in the black circle problem I was able to visualize how it would be moving so I was able to come up with the distance formula solution but with this one I couldn't visualize what was happening so it took me time
$$$B$$$ is also hard ._.
Sucked without seeing small $$$n$$$.
Not quite, B is just tricky
Not quite, A is just output.
A is guess-forces
no, the constraint has
k<=1414
, hinting a factor of root of 2 occurred someherewhich gives an hint towards the formation of square with side length =min(x,y)
well, at least i guessed and got it right
literally
Idk why i'm getting TLE in A. the constraints were pretty lenient for O(N * N) solution 288664487
Actually, the constraints are on X,Y and K in each test case, not on the sum of them over all test cases. So time complexity of O(XY) (or something else that is second order) requires a worst case of 1000*1000*5000 calculations, exceeding the time limit
Yeah, i realised that after fucking up my contest :(
What the hell is this Problem B?
took 2 minutes for A and 2 hours for B
hardest B i've ever seen fr
Actually I found A harder than B.
I feel like you either observe the solution instantly for A or you don't at all.
i literally kept testing everything I could think of on A and somehow it passed
Well, you just had to fix any two points of the two lines at the corners of the (x * y) rectangle, then vary the other two on x and y axes. I got TLE tho 288664487
5e3 * 1e3 * 1e3 = 5e9 , obviously TLE , you should always aim for <1e9 (unless the time limit is huge).
Oh damn, I forgot that test cases complexity too counts.
you did some overthinking, if y>k and x>k you can just make an "L" on the grid, and if k>x or k>y you make an X on the grid xd
I had that idea but idk why i messed up. This costed me the whole round, because i gave up on A.
Ahh, so it's not just me? I literally have NO idea how people managed to come up with B's solution in such less time :(
I guess since n was low enough for n^2, for odd n we can just brute force as we need to insert one extra number anywhere in the given array. Obviously, only at max 2*n possible values as we want new number to be closest to each a[i].
B is a standard problem, and it took me nothing to figure out the solution.
how to solve E?
How to solve D? Is it a Segment Tree?
It's just some prefix sum stuffs
prefsums + binary search. you can check my sol https://mirror.codeforces.com/contest/2026/submission/288582700
damn that's a lot of prefix sums
i gave up after trying too much prefix
I used $$$4$$$ different prefixes in total ._.
Yea I just upsolved it and this problem was a pain. It took me quite a bit to implement it and iron out all the bugs...
Also not very "educational". It doesn't really teach you to think differently, just "implement harder".
(assuming 1-based indexing everywhere) consider the b array as divided into blocks as this: (n size block) (n — 1 size block) (n — 2 size block)..... now consider one block which has starting element of pair as i. what is the sum of this block? s(i, i) + s(i, i + 1) + s(i, i + 2) + ... s(i, n) where s(l, r) is sum of a from l to r. you will see that in this expression, a[i] is added n + 1 — i times. so calculate suffix array on a[i] by this rule (a[i] * (n + 1 — i))
now if i want sum of k blocks, i need sum of block 1, sum of block 2, ... sum of block k i.e. suff[1] + suff[2] + .... suff[k] so create a prefix array on the suffix array created before.
now consider this problem: we want to find sum 1 to x, in array b:
first find number of blocks that are completely covered say k — 1 (use binary search) add pref[k — 1] then we are at block k, now if this block has l as left point of the pairs. we want to find (l, l) + (l, l + 1) +.... (l, l1) (l1 depends on where x lies in this block. now for this we can add suff[l] — suff[l1 + 1] directly. but note : this followed rule (a[i] * (n + 1 — i), but now a[i] has not been added (n + 1 — i) times. you will see that now a[i] has been added (n + 1 — i) — (n — l1) times. so you need to subtract s(l, l1) * (n — l1). again have a prefix array on original a for this say this answer we calculated for sum of b from 1 to x, is given by f(x), then given query is answered by f(r) — f(l-1).
I saw lots of max flow solutions.
me too, but why them work?
The solution is a direct application of Project Selection. Here is blog about this: https://mirror.codeforces.com/blog/entry/101354
Why is div2E max flow :(
I hope there are simpler solutions
is flow hard?
answer is n — max pair matching in the graph, where left side vertices are 1,2...n and right side 0,1,2...59 ,edges i <-> j where a[i]'s j-th bit is set.
B?!!!! Why is n < 2000? Is it really n^2 for odd n? How to solve B?
Yepp just brute force for every index For every index I push a[I] +1 just after a[I] and then check the minimum among all maximum You can see my code
Thanks, can you give a case where the picking the either last or first doesn't work for odd n? I couldn't come up with such a case
For n= 7
1 2 3 1000 1001 1002 1003 It's optimal to add answer is 1 If I add 4 after 2nd index (0 based) And then pair (1 2) (3 4) (1000 1001) (1002 1003) But If you add in begining or end it will be 997
Thanks got it!
5
1 2 20 25 26
yeah, for even N you just sort and pair up, and for odd you test all possible Ai that you could pair up with the extra cell
You can do in O(n + log2(max(ai)) using binary search. You can check this comment.
I did it with o(n^2). You can actually remove each element and cut the array at that position to make the array two even array and solve it.
I think this intuition is less complex to solve the problem. By also accepting o(n^2) authors try to make the problem simpler.
I did it in O(N). You can check out my solution: 288539510
Nice, using suffix and prefix max
Could you explain your solution?
please don't write problems like B again
What is the solution for B?
You can binary search for each k from low = 0 and high. = (arr[n-1] — arr[0])
why
return cnt >= n/2;
how you got this idea?
I will try to explain it here, let me know if you get it or not.
cnt is the count of pairs, number of pairs should be n/2, as 2 elements make up a pair. Also imp thing is we only have to check diff between conseq elements as least diff of any j with current i will be when j = i + 1 as array is increasing. eg: if n = 6. there should be 3 pairs. if n = 7, there should be 3 pairs and the remaining 1 we can match by adding our available "atmost one addition case".
n is even : Lets say a = {1, 5, 8, 10, 13, 14} and k = 3 here 1 and 14 would not get a pair (as (5-1) = 4 > k & 14 doesn't have a pair to match with), whereas (5, 8) and (10, 13) can make up pair. So cnt = 2. As we can only add atmost 1 number, we can't make pair for both 1 and 14. So k = 3 is not feasible. if cnt was 3 (= n/2) then that means all the numbers have pairs. So its feasible.
n is odd : Lets say a = {1, 5, 8, 10, 13} and k = 3 here 1 would not get a pair (as 5-1 = 4 > k), whereas (5, 8) and (10, 13) can make up pair. So cnt = 2 (= n/2). As we can only add atmost 1 number, we can make a pair for 1 by adding 0. So k = 3 is feasible.
ok got ,good explanation man :)
observe if we have
n==even
, then we cant take the extra element as that can't be compensated by any other element while making pairs so just find the max difference b/w consecutive elements, ifn==odd
, we have the choice to leave one element and find an extra new one for it, we can do this for each element and store the max diff to the right of it and to the max diff b/w consecutive elements to the left of it and take the max of both the overall answer for this case would be minimum of all such casesSolution can be seen here : https://pastebin.com/WyE4dwSL
My idea is also similarly. But I increment the iterator for even case with i++ instead of i+=2, and I spend whole 2 hours thinking some edge cases for odd case.
Now I get the mistake.
c's gonna make me cry when i see the case im failing on
please don't write problems like B again
Actually, I think it's a very good and tricky problem. No one on my friends list got it on the first try.
after the first WA2, i waste about 50mins. at WA5 bcos i were minimizing the ans with 1e15 :(
What? It's just a standard binary search problem.
after the contest, i felt like it is somehow harder than the last div1+2
fr
Many low-rated people solved D in the last 15 minutes, I don't know if it's my skill issue but I don't think it is an easy problem. So please skip those who cheated.
Same with B ig
no wonder, D is ChatGPT solvable. in fact, first AC was done by hardstuck gray account.
I attempted only the first two problems and found both of them weird, or maybe I am making some blunders; I don't know.
couldn't solve any thing I'm mad but at least the problems are not guessing problem
I mean I like prefix sums, but prefix sums of prefix sums of prefix sums is too much man.
AC D at 1:59 :)
AC D at 2:01 :(
Thank you very much for contest.
I spent close to 38 minutes for problem A and got one wrong on B just in hurry of choices Struggle is real kn geometry problems
today D feels like a buffed version of 2009F - Firefly's Queries.
Which I regret haven't upsolve the problem yet...
But idk maybe I'd stuck on this anyway.
They are not similar at all.
E: Build a bipartite graph with n vertexs on the left and 60 vertexs on the right. For each 1<=i<=n and 0<=j<60, we add an edge if a[i] has j-th bit set on. For any subset of left nodes, the score is (number of chosen left vertexs )-(number of right vertexs with edge connected to chosen left vertexs ) = (number of chosen left vertexs )+(number of right vertexs without connection to chosen left vertexs )-60, then the answer is (Size of maximum independent set)-60. By the Konig theorem: In any bipartite graph, the size of maximum matching is same as minimum vertex corver, and (size of minimum vertex corver)+(size of maximum independent set)=n+60, we can calculate answer by any maximum matching algorithm.
Can you explain to me what does "set bit" mean ?
If the j-th bit of a[i] is 1. Or if ((a[i]>>j)&1)==1
Or just think of it as the classical Project selection problem.
The bits are the machines.
The numbers are the projects.
Awesome idea
That is... beautiful...
If i've submitted twice of one problem which one will be counted? If first one is hacked then second one counted?
the last submission that passes pretests will be counted
Thnak you!! But in current standing showing first one counted!!will this updated?
There is nothing educational about B.
B reminds me with this problem
It is quite similar to "socks 2" of ABC although a bit different
im really confused why my binary search submission failed on B, and then my brute force one passed. obviously n is 2000, so i kinda knew it was brute force, but i didnt come up with any counter test case for my binary search one, can someone give a counter example?
try this
5
1 2 4 6 7
i get 1 on both of my solutions
Binary search would pass. I did it with binary search.
In problem E, what does "set bit" mean ?
bits that are 1 in the bitwise OR
Thank you, I thought that it the last bit which equal to 1, so I used Dp and got wrong ans
But how you become CM without knowing what is set bit. I'm not insulting you just curious to know
This is the first time I have ever knew about " set bit " word. I call it is "bit 1" :D
https://mirror.codeforces.com/contest/2026/submission/288585044
can someone help why this is wrong?
Greedy solution. Logic is that I store all the i where s[i] == 1 in a greater int set. ans = (n*(n+1))/2
I iterate over them{ count = 0; I have 2 variables l and r, I iterate over l from n->0. if I find s[l] == 0, then count++; if I find s[l] == 1 then I check on count, if it is 0 then I move more left.
When my 0s are exhausted, I move to r and only check the 1s from 1->n, if there is a 1 corresponding the I make count++, if there isnt then I break,
if there is a count then I reduce the answer by the indes of the one in the starting loop}
The algorithm I used:
In 2,3 just store the i, in these cases only, you will be saving money.
Yep I have done this only. Implementation is a bit different but yep
If
s[i] = 0
, the value $$$i + 1$$$ would be added to thecost
no-matter what.Go from right to left. The idea is to greedily exhaust the rightmost $$$1's$$$ with the first encountered $$$0's$$$ from right to left. If we exhaust in pairs, we will be able to remove as many $$$1's$$$ as possible.
Use a
std::deque
to store the cost generated by $$$1's$$$. Larger values are stored in the front.if
s[i] == 0
,if
!dq.empty()
dopop.front();
if it is empty, we can pair it with the already exhausted $$$1's$$$.do
cost += i + 1
if
s[i] == 1
dodq.push_back(i + 1)
. Finally when thedq
contains $$$1's$$$, we can greedily exhaust the largest(front) and smallest(back) values.https://mirror.codeforces.com/contest/2026/submission/288593783
Consider
1100011111
Does anyone know what's wrong with my solution for B at 288576824? It seems to me like it should work, but sadly it fails on test 2.
Check my braindead solution (that divide to 2 cases of N like you): 288562462
(Why braindead? It just bruteforce every possible choice of "removal" in case N is odd and find the "best" choice (variable "minn")).
(Case N is even, my solution is the same as yours)
PD I know prefix sum. But just too heavy implemention... run out of time. :(
yea, i gave up on d too
same.
Do I understand right that problem F is just:
Code persistent queue on 6 stacks, in stacks we store knapsacks, so when answering the query we can just take left and right knapsacks and bruteforce the sum on each edge
Is large number in cpp necessary to solve problem D?
Is there a great large number template in cpp? emmmmm
nah, it is just 10 millions prefix sums
how to solve C?
I transverse the array from back to front and use deque to be able to pop front efficiently. The greedy part is to match higher indexed '1' with any first '0' found and pop it. Then, if there are still '1's remaining, just pick the lowest half.
main take away is just greedy and 2 pointers
I was knowing it was greedy and came up with this idea but couldn't implement again. Fck my implementation skills fk it
Chill mate, look at me hard stuck in pupils for 4 months already and still die trying. You peaked in specialist is a good stuff, keep going.
ahh mate I peaked there I am trying really hard right now solving 1300-1500 range alot hoping to improve soon
wrong A why cant long long ? https://mirror.codeforces.com/contest/2026/submission/288534007
0 0 68724335200 68724335200 0 68724335200 68724335200 0 0 0 68724335200 68724335200 0 68724335200 68724335200 0 0 0 68724335200 68724335200 0 68724335200 68724335200 0 0 0 68724335200 68724335200 0 68724335200 68724335200 0
wrong output format Expected int32, but "68724335200" found (test case 1)
Looks like weird behavior because of reading before and after
sync_with_stdio
. Place it at the beginning.thanks
Can anyone try to hack this submission? I think greedy cannot pass this problem.
In these contests, is wrong answer on Test 1, considered as a penalty ?
I don't think so. Someone has commented about it here: Link
Thanks a lot!
Either I am getting dumb day after day, or A,B,C are actually getting difficult contest after contest.
Yesterday was Div (1 + 2) contest.
Today it is simply Div-2 contest.
I felt like today's ABC were more difficult, than Yesterday's ABC.
Nope
Today I solved ABC, but yesterday C was giving me an insomnia...
I also found yesterday's B much easier than today's A or B. Both today's and yesterday's A were a bit more complicated written than usual. Today's C was much easier (at least for me) than yesterday's C, sadly I ran out of time. :D
Worst contest is codeforces history.
Why is 1 blunder in 1 single contest worth a -150 delta?
A had a really nice hint for the idea that
AB, CD are diagonals of a square
with sidemin(x,y)
i.e. K<=1414 , hinting the appearance ofroot of 2
Problem E seems familiar
Problem C seemed quite interesting to me, the idea felt so satisfying.
Could anyone please explain how to do B? I used binary search, but it didn't work.
just brute force the point which will be paired with a point outside the given set.
you could use binary search or brute force (idk the binary search way)
but in the bruteforce way, if n is even, you just pair up all cells, and if its odd, you test removing every cell and pairing up the others to see which way is cheaper
Thank you. Got AC.
But I'm still wondering why my BS solution didn't work.
Anyways, thanks.
np!
Cause you have added random things in your code which is greedy when you saw the sample test cases
if(n%2!=0 && !x && (((num[i]-num[i-1]+1)/2<=mid) || i==1))
i) why i==1 is getting a free choice
ii) why n%2!=0? it makes no sense. If you approach is because you are already going to use one point to get even points then you are correct but making such mess in the same line? Cause later you are doing i==1 which means you are skipping a element at position = 0. Which again makes no sense cause you can pair any of the i so why position i=0 is getting a priority?
iii) (num[i]-num[i-1]+1)/2 <= mid makes no sense because the new point you will be placing will be not at the middle it will be anywhere ITS FREE WILL. By placing it at the middle of num[i] and num[i-1] gives no contribution cause you are meant to stick the power up for the first element that violates the <=mid thing with its next right neighbor (according to greedy approach).
I hope you understand that you have just written many wrong things and messy in a single line.
Dont be sad or angry about it. Understand it calmly and keep grinding.
If you need my bs approach (a clean code) https://mirror.codeforces.com/contest/2026/submission/288520406
Thank You!
No I got it. I should have read the question carefully to fully understand it. Couldn’t give my best performance today.
Its okay buddy. Sometimes we perform good and sometimes we perform bad.
Cheers that you are consistent with giving contests! Keep grinding 😇
It's optimal to paint neighbors.
why this case 2 and not 1 please answer
we can paint cell number 2 what is wrong with that ?
You have to choose two cells at a time. In this test case the no. of cells is even. So you can't choose any cell outside this given set.
Miss chance to become master AGAIN by declaring $$$a_i$$$ of Problem E as
int
, notlong long
.Note: shifting more than bit width is an undefined behavior, so I get WA1, not WA2 or WA3, which is confusing to me.
D is very reminiscent of Mosaic from this year's IOI.
Can anyone please explain why my solution fails:
Method: For even n, directly calculate the max distance between all pairs (a[0],a[1]), (a[2], a[3]).....
For odd n, calculate min(max(((a[0],a[1]), (a[2], a[3]).....), ((a[1],a[2]),(a[3],a[4]).....))).
Submission
Consider
1 2 10 20 21
Got it, thanks a lot.
The worst contest in codeforces history
Spent a lot of time thinking about E after coming up with the obvious Maximum Matching algorithm, not able to believe its actually the intended solution.
While not having a template for it cost me today's E, I am really surprised Maximum Matching was allowed to appear in E, especially when the idea that each bit should have atleast one unique entry is quite simple.
I agree that it is too much for E. But it seems to me that we have no right to complain, since this is Educ and in fact it is intended for this: you know an algorithm — 3 minutes will be enough for you, if you don't know — you are cooked for the next two hours.
"Euclidean or Manhattan" missing from "A"s statement.
If it's not specified I think you can just assume Euclidan
Are there any ways to solve problem E with dp? I tried to solve it with dp but get WA.
Let dp[i][j] represent the value of mask such that the number of 1-bits in mask is minimized when constructing a subsequence of length j with i as the last element of the sequence.
I think we can combine with some greedy tactics, such as save more than one mask for each dp[i][j] at a time.
Sorry for my bad English.
No it's not possible because even a mask where the bits might not be minimized might be better for bigger j and many other stuff
The worst contest in codeforces history
Using random to solve E: (This is gonna WA on test 2) (OMG, it's running on test 10!) (OMG, it's running on test 20!) (OMG! It ACCEPTED!!!) (I'm going to submit a lot of them to ensure I can pass main test) (passed 6/27) (ALL 6 AC submissions are hacked, rank 103->511 QAQ)
So is there a way to hack these submissions at a high possibility? Or it was just because I was to silly when randomizing? Can these submissions be hacked? 288611596 288611196
Okay, I've come up with a hack and hacked myself:(
thank you counterexample lmao, this one also breaks my code for some reason
for problem B this case
why the answer is 2 and not 1
if k=1 then we paint 1 and 2 and then we can easily paint 2 and 3 ??????????? why I'm reading the statement wrong every time ????
You can only paint WHITE cells. So, after you paint 1 and 2, cell 2 will be black, so you can't use to paint 2 and 3 since you can only paint white cells.
i spent a few seconds thinking the same thing during the contest lol
notice that the problem statement mentions in bold letters that you can only paint white boxes. once you've done the operation on 1 and 2, 2 becomes black so you can't operate on the second box anymore.
Seems that problem F only have operation 3 in the sample. See here
code copied from jiangly's code and add one assertion on operation 3. Only have 96 tests during the contest while the verdict is RE on 97.
My bad :( We only discovered that during the contest. Somehow all incorrect solutions we had were incorrect even on that set of data and all correct were still correct after the generators got fixed. Luckily, not a lot of people got affected by the incomplete tests.
I now got affected due to some runtime error that only fires if there's actually operations of this type in the input.
.
could someone provide counter example for this submission , im getting WA on test 5, and the solution seems kinda silly but it runs in O(60*n^2) in worst case scenario, and it seems correct to me. basically what i do is for every element i, lets call it valid, if for every bit that is set in in a[i], it has atleast 1 valid neighbour. first we assume all indices are valid, and then we check if there is an element that isn't and if there is such an element we delete it, and also since it may have made some other indices valid, but now doesnt anymore, we have to repeat this until no changes occur. this runs in O(60*n^2) in the worst case where we delete 1 element per iteration, and every element will be deleted, so its fast enough. but its getting WA on test 5 and i cant seem to find a simple counterexample.
nvm, got it
i went from getting a +65 in yesterday's contest to literally not being able to solve a single problem today. cf contests are SUCH a rollercoaster i swear :\
Sorry Demon_Master
Educational contest educated me that I know nothing. Nothing: No, you don't know me. Me: He knows me. He: Who, are you? Who: No, I am not "?". Not: No, your not Not. No: I know.
C was easier than B, also A was weird. not a balanced contest tbh,
The pretest of B is quite weak.I solved 5 problems, but I hacked my own B successfully.
What the hell was that B question ?? After several incorrect submissions, I came to a conclusion that its a BS + DP problem.
For even numbers, it is only possible to paint them pairwise from left to right. For odd numbers, you can delete one element and solve it as even numbers.
you can bruteforce it: for n even, just pair up all values, for n odd, fix every value and pair the others and see which way you get the minimum cost
I can't figure out why this code got WA on D. How mysterious.
Hard A. However, 3k people solve it in 5 mins. I DO think lots of cheaters in A. D is good. I need to practice more prefix sums, to find indexes faster.
can someone explain why this solution is not working for c ~~~~~
include
include
using namespace std; int main() { int tc; cin >> tc; while (tc-- > 0) { int n; cin >> n; string str; cin >> str; int s = 0, e = str.length() — 1; long long ans = 0;
} ~~~~~
please help me to find why this code is not working for c https://mirror.codeforces.com/contest/2026/problem/C
Awesome contest!I am rank 3 and will become IM!
orz
Why unrated?
Ratings will change in sometime i guess..
But unrated allowed maybe.
MinusForces
problem D makes me feel like I'm not participating in CP …… All of the difficulty is to write the code. Too little about algorithm and too much about coding. Well, maybe it can help us improve our coding ability ……
problem E is also not good. If you know Maximum Weight Closed Subgraph you can solve it quickly, but if you don't know that you are hardly solve it.
I think Div .2 D and E should have good ideas without too hard code or too hard algorithm.
Isnt the point of Educational Rounds to teach these topics to a wider range of participants?
By your logic, Problem F is also formulaic for those who knows tree division — it is just to decompose the knapsack dp onto a tree. However, in my opinion an edu round is to be formulaic as it aims to educate.
In my opinion, Edu round is more important to teach participants how to solve problem rather than a specific algorithm. In most contests like ICPC, only learned algorithms is not enough, it's more important to know when to use it and how to use it.
It is acceptable to set problems like E or F. But I think problems which have more thinking instead of hard hard code or hard algorithm are better in a 2 hour edu round.
Where is the EDITORIAL of problem F?
sbsbsbsbsbsbsb
Auto comment: topic has been updated by awoo (previous revision, new revision, compare).
I enjoyed this contest. It was really good! I don't understand why this post is downvoted.
Why can't I earn points in the last two games?
For problem D
The approach to this problem starts by precomputing powers of 2 up to the maximum needed range. This allows us to quickly apply these powers to elements without recalculating them each time, making the solution more efficient. For each element in the array, we break it down into two parts: an odd part and the largest power of 2 it can be divided by. This decomposition is useful because it lets us keep track of how much "doubling power" each element has.
To efficiently combine elements and maximize the sum, we use a stack. For each new element in the prefix, we check if we can combine it with elements already in the stack to get the highest possible sum. We do this by removing elements from the stack that have lower effective doubling power, adding their contribution to the sum, and redistributing powers to make the current element as strong as possible. After processing each element, we push it onto the stack, updating the sum for the current prefix.
Finally, we output the maximum sum for each prefix, taking results modulo to handle large numbers. This approach naturally follows from the problem’s constraints, as maximizing sums by doubling requires managing powers of 2 and combining elements optimally. As a result, it’s not unusual for solutions to resemble each other since the problem’s setup leads directly to this method.
sorry everyone i cheated on this round on problem -B ,may god forgive me !!!!!1