Привет Codeforces!
Приглашаем всех принять участие в Codeforces Round #266, который состоится 12 сентября в 19:30 MSK для участников Div2. Как обычно, участники из первого дивизиона могут принять участие вне конкурса.
Подготовкой задач занимались Antoniuk и я. Это наш второй раунд на CF, и все еще надеемся, что не последний.
Выражаем благодарность Gerald за помощь в подготовке раунда, Delinur за перевод условий на английский, а также MikeMirzayanov за Codeforces и Polygon.
Разбалловка задач будет стандартной: 500-1000-1500-2000-2500.
Желаем удачи и высокого рейтинга!
UPD. Раунд завершен. Спасибо всем за участие, надеюсь задачи вам понравились.
UPD2 Поздравляем пятерку победителей:
1) dominator_hza
2) Final_Battle
3) free_pascal
4) vanhanh.pham
5) NUOUN
UPD3. разбор задач
Все с нетерпением ждут что будет дальше.
Если верить цветовой шкале, worse станет первым участником с белым ником
Станет скрытным.
Продолжайте в том же духе, worse
P.S. Интересно, можно ли таким методом обогнать Гену по абсолютному значению рейтинга?)
Ради него нужно вводить новые цвета и звания в нижней части шкалы)
Да еще и багу нашли, должен быть белый цвет, а у него дальше серый.
Это у всех тут обновление цветов запаздывает.
Думаю нет, в какой-то момент рейтинг будет падать на 1-2. Хотя вот если бы такик worst-ов было бы 500, то возможно:).
Блин порешать не смогу, жалко однако(везунчики удачи на кантесте):(
I really liked k-tree! Hope to see some more problems like that!
Решил посмотреть прошлый ваш контест, наткнулся на одну интересную задачу 431E - Химический эксперимент. Кто-то может мне объяснить её условие? Она точно на русском написана?
В каждый момент времени у нас есть колбы с h1, h2, ..., hn литрами ртути. Воды в колбах никогда не будет.
Первый запрос состоит в выполнении присваивания hp = x (то есть в p-той колбе теперь будет x литров ртути).
Второй запрос состоит в следующем: нам дано v литров воды. Мы можем выбрать некоторое непустое подмножество колб и произвольным образом (мысленно, вода в колбах от эксперимента не появляется) разлить в них эти v литров ртути. Более формально: пусть = {m1, m2, ..., mk}, где . Тогда мы должны взять любие такие положительные числа d1, d2, ..., dk, что d1 + ... + dk = v.
Мы можем выбирать множество и числа di как угодно. При этом мы хотим минимизировать значение величины .
Искомый минимум (то есть минимум по всем возможным парам (множество
, числа di)) надо вывести.
Brazil's ACM/ICPC First Phase will be held this Saturday, this contest came in a good time for a last preparation. Thank you.
мой последний раунд...
Вам ещё самый большой подъём делать.
Варианты того, что сегодня случится:
Получив нулевой рейтинг, codeforces воспримет тебя как только что зарегистрированного участника (у них тоже нулевой рейтинг), и со следующего раунда тебе придётся по новой идти к нулю с 1500.
Рейтинг станет отрицательным.
Ты станешь топ1, так как случится переполнение (если для хранения рейтинга используется тип данных вроде usnigned int):
unsigned int a = 13;
a -= 40;
cout << a << endl;
Вывод: 4294967269.
Codeforces на джаве написан, там нет unsigned
Даже помечтать worse о топ1 не дал...
Такое чувство, что даже если бы worse и стал первым, то он так бы и "висел" в ТОПе вечно
а что если...
И в самом деле.
it won't be 500-1000-1500-2000-2500?
no it will be :D
just a moment ago KaiZeR haven't show score...
UPD: duplicate english comments
i really shocked when see only 4 comments :D usualy it's in order of 50-100
how will be destiny of worse ?
He discovered a white color under the grey wow :D
but i don't think there is a negative rating he will just stop at zero :D
[UPD] He got negative rating now i'm surprised :D
No!! He has broken all the barriers!
Even before tourist could reach 3300, he has splurged to -37 ! Unbelievable!
[Rating graph of worse... ]
He/She has registered
In the last contest his/her rating changes was
-48
. tourist missed rating3300
for a single point in his last contest. Will worse touch the0
rating ???I don't think he uses Russian version
But he does speak Russian, you can see this from his comments
I think users didn't find any specific problem in the text of the blog entry or ... to talk! Everything was ok :)
Wow! tourist just finished in 22 minutes!
Where is scoreboard for out of competition participants?
There should be a check box to toggle on/off for unofficial.
Is there any problem in java compiler?
Is there any problem in java compiler? Runtime error for me even in custom invocation, working fine in my computer. UPD- BigInteger function nextProbablePrime() giving runtime error on codeforces.
.
Really?
UPD. same in G++ 4.7 w/o C++0x
hard math contest !!!
sometimes easy math is very hard , how to solve B?
If you'll increase both numbers by more than 1e5, then product will increase by more than 1e10. But it is clear that you can get better answer, so you may check only all possibilities of increasing one of numbers by 0..1e5, and for every such possibility calculate required increasing of second number.
i did increase to sqrt(6*n), it's correct
Maybe I'm misinterpreting, but how would this method work for something like
1000000000 1 3000000001?
EDIT: Never mind, indeed misinterpreted.
2 3000000001
Задача С баян вроде. http://mirror.codeforces.com/problemset/problem/21/C
Правильна ли такая идея для Е:
Сохраним все запросы 3 типа в мап по документу
Далее пойдем по запросам сначала: если 1, объединяем героев в СНМ, если 2, то проходимся по мапу и смотрим был ли тот о ком спрашивают в одном множестве с тем кто подписал, сохраняем в ответ
?
Вроде нет. Дерево 4->3. Документ приходит 3, 4й его не подписывал, но в одном мн-ве.
ок, понял свою ошибку. Спасибо.
А теперь у меня вопрос: Та же самая идея, но в СНМ добавить уровень вершины в построенном дереве, сливание 2х множеств производить руками и полностью переписывать в одном из поддеревьев уровни вершин. Для ответа на запрос, смотрим что обе вершины в одном дереве и проверяемая выше.
Почему это не работает?
UPD. Отбой, у нас могут быть вершины-не предки выше получившего пакет.
how to solve D??
DP[i][j] — how many ways to solve first i points while having j open segments.
You have following moves at position i:
And for every possibility you should check that number of segments covering position i after such move is h-a[i];
Answer will be in DP[n][0] (you solved all points, all segments were closed).
Also there is an O(n) solution 7772910
Yes, and you can also improve naive DP[i][j] to something similar to your solution, that will also work in O(N), noticing that we should care about only few values of j for some fixed i (if j<h-ar[i]-1 or j>h-ar[i] then it makes no sense).
Thanks very clear explanation
A simple linear solution. Consider the sequence bi = h - ai. If some two bi, bi + 1 differ by more than one, the answer is 0, since some two blocks begin or end in the same position.
Otherwise the answer is the product of values val(i, i + 1):
What does Val mean?
What is the meaning of val(i,i+1) here?
Imagine that ending a segment and starting a new segment is the same as putting a red border between two cells: see this picture:
The white cells must be covered by the segments [l;r]. Thus if $$$b_i \neq b_{i+1}$$$, we must either end a segment (if $$$b_i > b_{i+1}$$$), or start a new segment (if $$$b_i < b_{i+1}$$$). If $$$b_i = b_{i+1}$$$, we can either end a segment and start a new one, or do nothing.
$$$val_{(i,i+1)}$$$ is the number of ways to do that in each case. In the picture, $$$val_{(i,i+1)}$$$ corresponds to the number of ways you can put a red border between the $$$i$$$-th and the $$$(i+1)$$$-th columns. Note that you cannot put more than two red borders between the same two columns $$$i$$$, $$$i+1$$$.
Thanks :)
В задаче E заходит : 7767621...
http://mirror.codeforces.com/contest/466/submission/7771298 — то есть такое нормально? где в условии написано, что нужно указывать стороны в ответе в таком же порядке, как и в условии?
Выведите три целых числа s, a1 и b1 (a ≤ a1; b ≤ b1) RTFM)
Я невнимателен, прошу прощения за вопрос. Весь контест думал, что неважен порядок
I think this time problem B was one of the hardest problem B's I have ever solved...
Yeah, I was confused about how to solve (a + x)(b + y) ≥ 6n where x and y are the number by which a and b are incremented. I tried to solve this for most of the time and I couldn't concentrate on problem C because I couldn't solve B!
Either x or y is small: just check all values up to million
A lot of us tried a greedy approach or maths, making it seem tough, but a brute force approach would have solved this.
As pointed out by I_love_Tanya_Romanova and aaaaaaaaaaaaaaaaaaaaaaab in the comments, both numbers cannot exceed 1e5 (LeBron's idea) or sqrt(6*n) (AvadaKedavra's idea). You just check a or b for all possibilities from 0 to 1e5 or sqrt(6*n) and calculate the required increase of the second number.
I think this time problem B was one of the hardest problem B's I have ever not solved...
I think this time problem B was one of the hardest problem B's I have ever solved...
Ironically, though there were few solves, the tests for B seem to be pretty weak — my submission 7762305 was accepted despite failing on many many tests (any of the lines in http://pastebin.com/rP0u5f4t would result in WA) due to having > rather than >=.
The actual problem was pretty nice itself though — proving that the solution will run in time is not too simple or obvious.
Seems like there was some miscalculation of the problems' complexities :D
Thanks for this. I should not be happy for solving the C question for the first time. :(
Hard but nice problems!
Rank: 235 , best performance so far. :)
Biggest mistake that I made was locking all solutions when I did not have any intention of spending much time on hacking.
Solution B got hacked. Could not resubmit. :(
Probably will remain EXPERT for some time.
Congrats, I too had my best performance so far today! Solved E for first time! :)
can anyone tell me why this solution gives WA while it works for that case on my pc http://mirror.codeforces.com/contest/466/submission/7772471
Not sure if that's the cause but a thing I notice is you do not return 0 in the end of the function, so I suppose the returned value is undefined, therefore it may return true at some moment?
i donot get it can u plz explain more how can it return true?
Well you don't return 0 if the function doesn't find an answer? You know, a function must always return a value. Since you don't tell it to return 0 (false) it may return whatever it likes in theory :D
yes right but in that case i donot call the function
but that was the bug weired
That bug was the difference between me and div 1
You do call it. 6*11=66, while 7*7=49, so n>a*b, therefore you do call the function.
the contest effect sorry
Finally worse did it.
Congrats to worse for becoming the first ever white coder on codeforces !
Even though ratings have been updated, colors have not. I am a specialist with rating 1553. :P
I guess they are struggling with assigning white color to worse.
Looks like
Exception in thread "RatingUpdater"
:Dworse has broken the system :)
Ограничения по рейтингу для div2 1-1699, интересно сможет ли worse принимать участие в div2 теперь.
да и цвета для него нет.
Жизнь — тлен! ;(
What happened to my account rating ? http://screencast.com/t/pdEJQN5CZu
Probably worse's today achievement completely distorted the global rating update system.
Me too... http://mirror.codeforces.com/contests/with/Tudor
так-то dalex прав был про worse http://mirror.codeforces.com/blog/entry/13121#comment-179480
I solved nothing but A this contest.
I've actually solved E(for the first time in my life) but made a simple mistake. In one of the lines, I used the variable which I use to count the number of tasks received till now instead of the variable that holds the number of task that is in question... Passed pretests but got WA in system tests :( I suspected that I'd get TLE in system tests but when I corrected that line I got AC...
Anyways... Let's look at the bright side.. I've solved my first E even though it's not official.
This is first time I solved problem E! :D And became candidate master! :D :D
At first I got many WA 3 times on problem 1, I thought that for sure I will become Specialist again (got Expert only in previous contest).
After A passed pretests, I tried C and again got WA 2 times... tried E and got TLE. Finally I tried different method and E worked, then turned out I had to use long long int in C and that passed pretests as well.
Edit: I previously asked about other solutions to E, but I found a very simple one now.
I am unable to guess why my code gives WA plz can someone help me find the bug .Here's my submission http://mirror.codeforces.com/contest/466/submission/7774444
Wow , nice submission id 7774444
It's a lucky number according to Codeforces Beta Round 84 (Div. 2 Only) :D
though, his submission unluckily got WA
It must have only been nearly lucky :(
Why is that so? I mean lucky !
У меня видимо забавный баг. При рейтинге 1709 у меня зеленый цвет. Что мне с этим делать?
Это все worse сломал, скоро админинстрация починит, наверное
UPD: О, ты уже фиолетовый. Странно, я еще нет
So, apparently E had weak testdata. Or else, How did this solution pass? http://mirror.codeforces.com/contest/466/submission/7765318 I can break this solution with very easy testcase.
there are many question like this with weak tests... anyway after this time if i cant solve a problem efficent i will send a naive solution :|
Can you give one?
I think an input of the following type would work:
Basically, the idea is that we have a chain of bosses 50,000 employees long, with 500001=>50000=>...=>1, so 1 is the boss of everyone. Then, we have 25,000 documents. Each document we give to employee 50,001 and we ask if it reached employee 1. It seems like you're doing a linear search for each document. So your running time will be on the order of 50,000*25,000 = 1.25 billion operations.
Ah, you are correct. For some reason I assumed maximum height of tree as log(N + M).
I jumped to exactly 1700 in this contest. Now it appears that I am in some sort of bizarre limbo...
[UPD: Fixed now, as add1ctus said.]
You are a candidate master, but it seems that worse broke the rating system by getting negative rating (thus not fitting into the 0 — 1199 gray rank, but in a new color — white). Hopefully once it gets fixed you will be promoted to candidate master.
I see, thanks!
It seems, there is a bug in standings table: purple participant is impossible for Div.2.
There is a bug with the rating/rank system. He had 1472 rating before Round #266 and got promoted to purple after the competition. Check his profile.
What happened to phantom11's country-wise standings?
I couldnt understand the concept to B. Anyone?
If a >= sqrt(6n) and b >= sqrt(6n), then a*b >= 6n; in this case, do nothing. Let a be the smaller of the two input numbers, and b be the larger of the two.
One trivial solution is to increase b until the room is big enough. E.g. if a = 10, b = 11, 6n = 1001 (somehow): then the trivial solution is 10*101 = 1010. Then your "overflow" is at most a, which as we said was <= sqrt(6n). Let TRIVIAL be the value of this trivial solution, i.e. in this case, 1010.
Therefore, the optimal solution has "overflow" at most a. Suppose that the optimal solution is x*y, with x <= y (WLOG). Then x <= sqrt(6n) + 1, because otherwise, x*y > (sqrt(6n)+1)*(sqrt(6n)+1) >= 6n + 2sqrt(6n) > 6n + a >= TRIVIAL, therefore the solution was non-optimal.
What we have shown is: you are guaranteed that an optimal solution exists with at least the smaller number being less than sqrt(6n). It is possible that one of the two is larger, though, e.g. 1*6n = 6n. However, your goal is only to find the smaller number, through the following method.
Fix w between 1 and sqrt(6n). For every w, let h be the smallest integer s.t. w*h >= 6n, i.e. h = ceil(6n/w). Keep track of the best value you've found so far. Then, you iterate through sqrt(6n) < 10^5 possible values of w, and for every such w, your computation is constant time, so your algorithm is linear in sqrt(6n).
Here is my code : http://mirror.codeforces.com/contest/466/submission/7796449 In my computer and ideone.com http://ideone.com/6lt8wR it runned test 1 and give me 4 but on codeforces it give me 0 ??? Who can explain me ??
Similar is happening with me too. My submission gives answer as 2041 for input test case 2. However on ideone and my local compiler, answer is 1.