Автор PikMike, 9 дней назад, ,

Привет, Codeforces!

В 11.10.2018 17:50 (Московское время) состоится Educational Codeforces Round 52 (рейтинговый для Див. 2). Продолжается серия образовательных раундов в рамках инициативы Harbour.Space University! Подробности о сотрудничестве Harbour.Space University и Codeforces можно прочитать в посте.

Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ACM ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.

Вам будет предложено 7 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.

Задачи вместе со мной придумывали и готовили Роман Ajosteen Глазов, Адилбек adedalic Далабаев, Владимир Vovuh Петров и Иван BledDest Андросов.

Удачи в раунде! Успешных решений!

UPD 1: Наши партнёры из университета Harbour.Space попросили донести до участников раунда беспрецедентное предложение о бесплатном обучении в Барселоне (плюс стипендия!) по направлению робототехника. Подразумевается магистерская программа в Harbour.Space University. Все подробности в посте https://codeforces.com/blog/entry/62357.

UPD 2: Жду всех желающих в местном Discord сервере сразу после контеста для обсуждения задач.

Поздравляем победителей:

Место Участник Задач решено Штраф
1 isaf27 7 263
2 HanwhaEagles 7 340
3 Seraphimon 6 251
4 CJYeong 6 273
5 -vjudge- 6 280

Поздравляем лучших взломщиков:

Место Участник Число взломов
1 Laggy 63:-10
2 Doriath 38
3 BohdanPastuschak 38:-7
4 Kerman 36:-6
5 zoooma13 33:-2
Было сделано 860 успешных и 719 неудачных взломов.

И, наконец, поздравляем людей, отправивших первое полное решение по задаче:

Задача Участник Штраф
A xiaowuc1 0:01
B xiaowuc1 0:03
C HanwhaEagles 0:07
D isaf27 0:33
E Kyouko 0:19
F mHuman 0:35
G tfg 0:44

UPD 3: Разбор опубликован

•
• +135
•

 » 9 дней назад, # | ← Rev. 2 →   -45 Educational aka KILL YOUR RATING contest in da house again!
•  » » 9 дней назад, # ^ |   +17 I think it's vice versa, you can really make comeback and get new high rating in Educational rounds.
 » 9 дней назад, # | ← Rev. 4 →   +2 PikMike and his Educational rounds :D
 » 9 дней назад, # |   +33 The greatest hacker halyavin will hack us. Thank you for finding bugs:D
•  » » 8 дней назад, # ^ |   +25 ^^Those hacks scare me after every educational codeforces round :(
•  » » 7 дней назад, # ^ |   0 upd: halyavin didn't appear in this round
 » 9 дней назад, # | ← Rev. 6 →   +85 я еблан
•  » » 8 дней назад, # ^ |   +3 Мы знаем.
 » 8 дней назад, # |   +18 Thanks to MikeMirzayanov for such a great polygon.
 » 8 дней назад, # |   +17 I like Educational Round very much!Thanks for Codeforces!
 » 8 дней назад, # |   0 Will all problems be about robots?
•  » » 8 дней назад, # ^ |   +3 No, about math
•  » » » 8 дней назад, # ^ |   0 +1
•  » » » 8 дней назад, # ^ |   -34 I just hope you're wrong... Though, sadly, I think you'll be right. I'd like to see a Segment Tree + DP problem, something with queries or string, or anything but math. It's like those kind of problems are out of fashion lately. Ugliness and boredom is what programmers are looking for apparently.
•  » » » » 8 дней назад, # ^ |   0 is what programmers are looking for I guess programmers aren't looking for math. Just, they are finding only that type of problems.
 » 8 дней назад, # |   -31 wow, I took a look at cf rounds after a long time, and now it turns out that educational rounds are almost rated for me (I'm away just by 110 points)
 » 8 дней назад, # |   0 I will serious in this test!
 » 8 дней назад, # |   +3 Thank you friends from Harbour.Space University
 » 8 дней назад, # |   -20 i cant rally undasternd if or no is rated?
•  » » 8 дней назад, # ^ |   +8 You always ask this question it's ridiculous, stop it please.
 » 8 дней назад, # |   0 Educational round! <3
 » 8 дней назад, # |   +24 ого пикмайк желтый))0)
 » 8 дней назад, # |   0 delay
 » 8 дней назад, # |   +19 Sorry, we had some troubles with preparing the tasks, so the contest is postponed to 14:50 UTC.
•  » » 8 дней назад, # ^ |   -8 It's a good sign of problems' quality xD
 » 8 дней назад, # |   +112 The delay !!!
 » 8 дней назад, # |   0 Good luck to everyone, have a nice contest!
 » 8 дней назад, # |   +18 ща будет пяцот комментов, что раунд перенесли
•  » » 8 дней назад, # ^ |   0 Раунд перенесли
 » 8 дней назад, # |   -44 OMG OMG OMG OMG OMG IS IT RATED ?? ? ? ? PICKMIKE DO NOT TELL LIE TO PEOPLE IT WON'T BE RATED!!! KEKEKKEKEKEKKEKEKEKEKKEKEK
•  » » 8 дней назад, # ^ |   -12 I want moooore dislikes
 » 8 дней назад, # |   -18 delayed :(
 » 8 дней назад, # |   -66 - :v
•  » » 8 дней назад, # ^ | ← Rev. 2 →   0 *It works
 » 8 дней назад, # |   +25 First contest. Wish everyone good luck and high ratings!
•  » » 8 дней назад, # ^ |   0 good luck!
 » 8 дней назад, # | ← Rev. 2 →   +12 I'm from Viet Nam, Hello everyone, that is the first contest. Wish everyone good luck.
 » 8 дней назад, # |   +26 Empty contest xD
 » 8 дней назад, # |   +11 Excuse me, WTF?
 » 8 дней назад, # |   0 What is happening to the contest?
 » 8 дней назад, # |   +20 Statements are so short, that they don't even exist!! Wow!
 » 8 дней назад, # |   +8 Where is the problemset??
 » 8 дней назад, # |   0 WTH, where are the problems? LOL
 » 8 дней назад, # |   +1 Might be helpful to copy the upd in the post to the comments)I'll be on the community Discord server shortly after the contest to discuss the problems.
 » 8 дней назад, # | ← Rev. 2 →   -27 what a nice problem D is!
•  » » 8 дней назад, # ^ |   +5 contest isn't finished!
 » 8 дней назад, # |   +84
 » 8 дней назад, # |   +18 Hats Off! A well balanced contest :)
•  » » 8 дней назад, # ^ |   0 it would be better if D was a little easier
•  » » » 8 дней назад, # ^ |   +25 better if D wasn't in the contest
 » 8 дней назад, # |   0 How to solve D?(My solution is bfs with lots of states, and will probably fail).
•  » » 8 дней назад, # ^ |   +3 I did bfs with state = (row, column, target_number, piece). This works because you process all states with distance 0, distance 1, distance 2, and so on, so if there is another state that arrives other states (already in the queue) you can update the min number of changes of that state.
 » 8 дней назад, # |   +19 What is F test case 4 ?
•  » » 7 дней назад, # ^ | ← Rev. 3 →   +3 I believe its a complicated version of this. 10 2 1 2 3 2 1 6 7 7 7 Answer should be 5
•  » » » 7 дней назад, # ^ |   0 Why the Answer is 5？
•  » » » 7 дней назад, # ^ |   0 I have draw this tree and the tree in test case 4. They are truly Homologous cases. But I cannot understand why the answer of this case is 5.
•  » » » » 7 дней назад, # ^ | ← Rev. 4 →   +3 You go 1 -> 4 -> 2 -> 5 -> 1 -> 8 -> 7 -> 9 -> 7 -> 10, covering all 5 leaves.
•  » » » » » 7 дней назад, # ^ |   0 I get it.Thank you.
 » 8 дней назад, # |   0 I coded problem D for more than 1 hour and I couldn't submit it for 30 seconds.
 » 8 дней назад, # | ← Rev. 3 →   +3 Took me way too long to notice that a semi-naive solution fits time limit in G (44152174) :(.F and G were very nice problems, but it's kind of silly that the hardest problem was D
 » 8 дней назад, # | ← Rev. 2 →   0 Couldn't debug my solution for C throughout the round and lost interest halfway :( RIP ratingCan someone help? 44139210
 » 8 дней назад, # |   +2 What is the 3rd test case for Problem C ?
•  » » 8 дней назад, # ^ |   +1 I had a wa on 3d test because my solution idea was wrong the answer is not the amount of cubes divided by k because each slice is not necessarily the same amount of cubes and anyway i just got hacked :( so sad
 » 8 дней назад, # |   +4 Is there anyone who solved D in djkstra's algorithm?
•  » » 8 дней назад, # ^ |   0 Me
•  » » » 8 дней назад, # ^ |   0 I didn't know that djkstra's can be coded with multiset XD I only used priority queue before what is faster?
•  » » » » 8 дней назад, # ^ |   0 Priority queue of course. How could it be slower when it implements a strict subset of the functions that a multiset implements :Dd
•  » » » » » 8 дней назад, # ^ |   0 That makes sense Thanks:)
•  » » » » » 8 дней назад, # ^ |   +3 Well, it depends. With priority queue implementations, usually you insert a node into the queue whenever you find a better cost for that node, which can happen O(E) times, therefore your priority queue with have O(E) size. With a set implementation, when you find successfully relax a node, you look it up and update it (which you can't do in a normal priority queue). Therefore, your set will have O(V) size and usually V < E in problems. I agree many times priority queue will be faster (I personally implement with priority queue as well), but the issue isn't as simple as "it implements a strict subset of the functions, therefore it is faster". The very fact that it is not as powerful means there's certain things you might want to do, but you can not (things that would speed up your solution).
•  » » » 8 дней назад, # ^ |   0 How?
•  » » 7 дней назад, # ^ |   0 Dijkstra is overkill, BFS is enough
 » 8 дней назад, # |   +3 dude, cool contest! thanks a lot
 » 8 дней назад, # |   +4 How to solve problem D
 » 8 дней назад, # |   0 Can anyone hack me?Please hack me!HACK ME PLS,PLS,PLS
•  » » 7 дней назад, # ^ |   0 What idiot wants to be hacked after the contest?
 » 8 дней назад, # |   +14 How to solve F?
•  » » 8 дней назад, # ^ |   +29 In addition to the directed tree, we add an edge from each leaf to its kth parent (or the root if there is no kth parent). Now we want to find a path which maximizes the number of different leaves on it, which can be done with SCC + DP.
•  » » » 8 дней назад, # ^ |   +26 Or for every leaf node find the node which smallest depth achievable by jumping to leaf to leaf and increase the value of that node(initial all nodes value 0). After we will do dp with our value of nodes. dp[nd] = max(dp[childs of nd]) + value[nd] Btw we will do first part by segment tree+binary lifting. Here is my code: 44154622
•  » » » » 7 дней назад, # ^ |   +4 Or we can use DSU to maintain SCC's with each connected component storing the number of leafs present in them. Then the problem will reduce to finding a path in a tree from root to leaf, having maximum value. It is quite simple to implement this. Here is my code : 44159892
•  » » 7 дней назад, # ^ | ← Rev. 2 →   0 When you running dfs,for each node maintain two value bk(can back) and dbk(dont come back),the answer is bk[1]+dbk[1].44179107 this code is short
 » 8 дней назад, # |   +5 what's the hack for c ? I solved it with binary search and just got hacked
•  » » 8 дней назад, # ^ |   0 I hacked few people with this test:5 63 3 3 3 3Answer: 0Your code outputs: 1
•  » » » 7 дней назад, # ^ |   0 fuck, I got hacked in this stupid test
 » 8 дней назад, # |   +13 whats the logic for E?
 » 8 дней назад, # |   0 How to solve C ?
•  » » 8 дней назад, # ^ | ← Rev. 2 →   0 heights of tower = th[1...n]max(th[i]) = mxmin(th[i]) = mnLet array B of size (mx-mn) , B[1....(mx-mn)] , where B[i] = number of cubes at height[i+mn]now problem reduces to find the minimum number of contiguous subsegments of array B such that sum of each segment is less or equal to k.O(max(n,(mx-mn)
 » 8 дней назад, # |   0 My solution for C got hacked but when I submitted the same solution again it's getting accepted.Can someone explain me why this happened?
•  » » 8 дней назад, # ^ | ← Rev. 2 →   0 same hereedit: after I resubmitted the same solution it got accepted and got hacked again lol
•  » » 8 дней назад, # ^ | ← Rev. 2 →   +3 deleted.
•  » » » 8 дней назад, # ^ |   0 Not true. Tests are added to the testset during the hacking phase, but it doesn't rebuild the problem packages instantly. You can expect the test to get added to the testset in like half an hour or so.
•  » » » » 8 дней назад, # ^ |   +1 Do you know the hack for it? My binary search got hacked.
 » 8 дней назад, # | ← Rev. 4 →   -14 long double g=ceil((1+sqrt(1+(8*m)))/2.0);if(m==0) cout<
•  » » 8 дней назад, # ^ |   0 i was solving this by same approach ..... i dont know what was i doing as i was using 4*m^2 and now i realized this is due to pressure..lol
 » 8 дней назад, # | ← Rev. 2 →   0 Nevermind.
 » 8 дней назад, # |   0 How to solve E?
•  » » 7 дней назад, # ^ |   +11 The problem turns into:You have 2 strings of same size (ignore the middle position if the size is odd) and you can swap prefixes of some given sizes. Find the number of equivalent groups.First, note that you can swap the intervals between the swap sizes independently. This means you can just count the number of equivalence classes in each group and multiply them to find the total number of equivalence classes.If you have a group of size S, you have A^S classes with both sides being equal and (A^2S — A^S) / 2 classes with both sides being different. After this, you just need to multiply A^(number of characters outside of groups) because they never change.
 » 8 дней назад, # |   0 In PROBLEM C: my solution is failing for 6th test case by 1; Can anybody help me in debugging??Submission
 » 8 дней назад, # |   0 great problems :) thanks :D
 » 8 дней назад, # |   +3 How to solve D?
•  » » 8 дней назад, # ^ | ← Rev. 2 →   +3 Hey natofp, I just solved it with dijkstra's algorithm. Try to minimize (moves, replacements) (sort by moves and then replacements)Then you can keep track of the state [3][node][level].The idea is that you can hit multiple nodes from reaching a to a+1. Therefore, we denote 1, 2, ... n as a separate dimension called [level] (the target points or breakpoints we travel through) We can just update level when the node we are on matches the next "level" in the path we need to hit.And then for the inidividual nodes along the way we have another dimension [node] which is just the current node we are on.And the [3] is just knight,rook, or bishop.As an implementation details, by n I actually mean the total amount of nodes so n = 100. If you do this way you have to convert numbers values to row/col and vice versa.My code: https://pastebin.com/ghseX4WT
 » 8 дней назад, # |   +8 Possible Case of Cheating! PikMike
•  » » 8 дней назад, # ^ |   0 Wtf comments?
•  » » » 8 дней назад, # ^ |   0 To avoid cheating detector I assume...But maybe hes just trolling and didn't cheat. I think the detector ignores comments anyways.
•  » » 8 дней назад, # ^ |   +6
 » 8 дней назад, # |   +3 If i hack someone will it improve my rank
•  » » 8 дней назад, # ^ |   0 no
•  » » 8 дней назад, # ^ |   +4 It will (indirectly) if you hack someone ranked above you.
 » 8 дней назад, # |   0 Is it possible to solve C in a fast way if we expand the restriction of 1 <= ai <= 2e5? I'm sure most who solved made observation that vertical was easier than horizontal (because the cuts were horizontal lines), but what about 1 <= ai <= 2e9, is there a good solution for it if we are forced to solve horizontally?
•  » » 7 дней назад, # ^ |   0 Discretizate ai and then use segment tree
•  » » 7 дней назад, # ^ | ← Rev. 3 →   0 Yeah, my solution was actually horizontal (still O(N log N) cause i gotta sort).https://codeforces.com/contest/1065/submission/44166753
•  » » » 7 дней назад, # ^ |   0 Thanks, this is what I was looking for.
•  » » » 3 дня назад, # ^ |   +1 My solution was horizontal as well, without the extra log factor because I didn't sort, but for some stupid reason I kept getting WA, so I decided to rage quit the contest and went play some Hollow Knight.
•  » » 7 дней назад, # ^ | ← Rev. 2 →   0
•  » » » 7 дней назад, # ^ |   0 By "expand"the restriction I mean make it bigger, so im asking for a solution where ai <= 2e9 instead (where this method wouldn't work, as I also used this idea)
 » 7 дней назад, # |   +13 Educational round and halyavin hasn't made a single hack yet? That's weird :P
 » 7 дней назад, # |   +3 Is there going to be an editorial? :)
 » 7 дней назад, # |   0 Why for educational rounds system testing takes very long to start ?
•  » » 7 дней назад, # ^ |   0 This round had a 12h hacking phase after which the system testing started.
•  » » » 7 дней назад, # ^ |   0 Yea 12 hour. But after 12 hrs it takes normally 1 — 3 hrs to start.
 » 7 дней назад, # |   0 Can we get rating in this race?
•  » » 7 дней назад, # ^ |   0 This round is rated for all users below 2100.
 » 7 дней назад, # |   0 Please some one explain problem C..
 » 7 дней назад, # |   0 Sorry halyavin
 » 7 дней назад, # |   +9 editorial?
 » 7 дней назад, # |   0 EDITORIAL ???