Всем привет!
Завтра в 19:30 MSK состоится Codeforces Round #240.
Это наш первый раунд на Codeforces и мы надеемся, что он вам понравится. Задачи были подготовлены авторами: Amir Keivan Mohtashami (matrix), Farbod Yadegarian (FarbodY) и Gerald Agapov (Gerald).
Традиционно благодарю MikeMirzayanov за системы Polygon и Codeforces, а также Maria Belova (Delinur) за перевод задач.
Желаем вам хорошего и интересного раунда.
Удачи!
Как обычно, распределение баллов по задачам будет анонсировано перед началом контеста!
Распределение баллов:
div1: 500 — 1000 — 1500 — 1500 — 2500
div2: 500 — 1000 — 1500 — 2000 — 2500 (стандарт)
UPD: Поздравляю победителей!
Div 1:
sankear (Единственный, кто решил задачу E во время контеста)
Div 2:
Статистика по раунду, подготовленная DmitriyH, находится здесь. Английский разбор можно прочитать здесь.
2 Iranian problem setters , that sounds great !
I wish it will be different and special round :)
Hope the problems be interesting like havaliza's problems :)
I think there will be a matrix problem :)
What makes you so positive?
Nickname of the topic starter.
is it only me that has received the announcement first time in Russian despite primary Language being English in codeforces?
I received the announcement in English
In fact,Everyone has been informed
I wish you all good luck and increase the rating
Do you know dibil power Ha ? this is 1000th dibil :D HURRAY DIBILS
oh no -44 HELP DIBILS
i don't know how, but i'm registered twice for this contest!
EDIT: sorry the image i initially posted was too large, so here is link to image
Thanks. Nothing dangerous. I'll fix it before the round.
cool thanks. but plz make sure to remove only one (not both) :P
i think the issue is fixed now. thanks for ur help! :)
Same here
May be the rating will increase or decrease twice ;)
I love coding too. :)
i wish it had! :P
Что то в последнее время с началом раунда какие то очень странные вещи происходят. Иногда высвечивает что осталось на 4 часа больше чем реально + при переходе на страницу с соревнованиями время начала стоит 23:30, потом обновляешь и все нормально.
можно скриншот?
в правке скриншот
А какое в этот момент "Время на сервере" (см. внизу в футере)?
И что там в скобках, p1?
уже обновил, пока все в порядке) как будет наблюдаться, посмотрю
сейчас время правильное, в скобках р1
В первой правке скриншоты. Время неправильное, внизу c4 вместо p1.
Спасибо, нашел причину, исправил.
в правке
Спасибо, нашел причину, исправил.
Спасибо, нашел причину, исправил.
Wish both Iranian problem setters, Amir Keivan and Farbod, Gold medals in this year`s INOI. Good luck.
Is the contest time 19:30 or 23:30?
Currently (at least for me), the time on the contest list is 23:30 and the counter shows that the contest starts in 6 hours...
Screenshot: http://koti.mbnet.fi/pllk/cf.png
Usual time. There was an issue around timezone support.
Delayed?
Delayed!)
Yeah. Probably related to the occasional crashes ("Service temporarily unavailable.")
Will it ended like TCO 2014 Round 1A yesterday ?
I hope not!
No, I think it won't be held next week, like TCO Round 1A.
number of registers keep increasing... from around 900 to 1000...
hey, has the round been postponed by 10 minutes? i suddenly see
00:11:42
in the countdown!i agree with you
nice hahdle
thanks :D
So you can vote for my handle :)
yes
Is the contest delayed ?
as you see
Let's hope it is not a problem like what happened in TCO yesterday.
Покажусь педантом и выпендрежником, но уже прошло время планированного начала контеста, а обещанного распределения баллов еще нет.
В англоязычной версии поста есть :)
Но начала контеста-то еще не было. Они пока не опоздали.
Is that server downtime ? I saw "Codeforces is temporary unavailable" page several times just before some minutes.
I don't know, but let's just hope everything is under control.
wish a nice contest
Что такое? Пишет осталось 4 мин, время проходит, и снова 4 мин, уже 3 раз.
ok you're right
Время до закрытия регистрации; Время до начала контеста; Второе время до начала контеста.
can we know the reason for delay?
last 30 seconds~~~~
In Problem B,I can't see the picture about "how much dollar a worker can get if he returns w tokens". Then what should I do?
LOL I think this is the first round I've encountered on CF that the English statement is correct instead of the Russian one.
I have a guess:
since the authors are Iranian then they wrote problems in English and then the statements have been translated to Russian ,during translating the mistake happened
What? There were 8 hocruxes? And 8th was hidden in Tom's CF account? One more HP movie? Harry Potter and Codeforces account LOL
In problem B the image was so bad i made one wrong submission before asking a question to clarify that the expression was floor (w*a)/b , i had earlier thought it to be floor((w-a)/b)
I too faced the same problem , and misread it floor ( (w-a)/b) instead floor( (w*a)/b) . Wasted 45 mins :(
Как решалась Б (див 2)?
вывести (x_i * a % b ) / a;
Блин.
Ну или так :D
Как вы получили такую формулу?
Ну если как в примерах a == 1 то сколько можешь баксов взять столько и берешь, остальные жетоны оставляешь. А если "a" больше, то нужно уже вспомнить что просто остаток от деления это уже не количество жетонов а, ну не знаю, очки какие-то. А вот если разделить на "а" то получится как раз количество жетонов, которые остались.
Спасибо, теперь понял смысл
Для каждого запроса одни и те же действия. Сначала посчитаем сколько денег работник получит если отдаст все жетоны, а потом бинарным поиском подберем такое минимальное количество жетонов, что если работник сдаст их, то получит столько же, сколько если сдаст все жетоны.Ответом на очередной запрос будет разница между выданным количеством жетоном и найденным значением.
это все равно что оптимизировать линейный поиск результата деления.
Я тоже подобное иногда делаю, когда формулы лень придумывать, ТЛ и не пахнет, а условие легко сформулировать) Но тут все же лучше было считать.
Why my solytion on problem C-div 2 gets TLE?
use this
or you could also use ideone
i find it more useful for sharing code.. :)
Your code ran endlessly when dealing with the special case
n=1
.thanks
or even paste ubuntu
Nice statements... Easy to understand... :)
Hope to see you again as author.... :)
nice contest...
made stupid mistake in B which led to me wasting too much time...
hope to learn a lot from the editorials... :)
thank you to the problem setters!
can you say what was the wrong i think i do same wrong
i took x-floor((floor(x*a/b)*b)/a) instead of x-ceil((floor(x*a/b)*b)/a)... took quite a while to realize this mistake...
isnt x%b enough?
nope... it is not enough... for example, take x=12, a=2, b=7... the actual answer is 1 but x%b gives 5...
so i couldnt understand the B
thanks
you're welcome
Pretest 4 is pretty strong.
if you are talking about problem C pretest 4 then i agree...
Actually I'm talking about problems B, C, and D.
Screenshot: http://i.imgur.com/b8M210d.png
i cant say much on pretest 4 until i see it, but i think pretest 7 is strong!
n=1 and k!=0 :D
:D didn't take care of that... :P
LOL , I made two wrong submissions one failed on pretest 4 and the other failed pretest 7
Annoying issue with printf: As suggested in the problem statement, I tried using printf to output the numbers for problem C, but I could not submit because of the warning. In the end I had to submit the cout version, which I am afraid might time out.
are u referring to the warning which says to not submit solutions using the
%lld
specifier in C++?In fact, we do not have any problem now even if we use
%lld
on Codeforces.luckily for u, it passed. but only just (
3447ms
)! ;)You can use %I64d, CF preferred %I64d. I used it instead of %lld.
I had the same issue. And it is really strange to have a warning with "lld" which is correct. And no warnings at all wile using "ld" and it seems like there is no situation when it could be useful.
Previously there was a bug in MinGW, and
%lld
did not work — only non-standard%I64d
did. Now it has long been fixed, but the Codeforces warning remains.Oh, I didn't know the bug. Thanks. I thought the reason of the warning was that CRT used by MinGW hadn't supported
%lld
in the past.Yes, it was exactly this.
I see. Many thanks!
Liked the problems and the statements specifically, though I couldn't solve Div2 E, lol.
Would be really great if some corner and/or extreme cases were excluded from the pretests.
Ну блин, что это такое? Второй контест подряд Div.1 A какая-то стрёмная жадность, а Div.1 B — элементарная динамика, которую решает больше человек, чем А. Я не могу понять отношения авторов контестов к сложности задач(
Скажите решение задачи А.
Я решал так — будем заполнять всё парами, у которых gcd равен единице, это числа вида (x;x + 1). А первой паре сделаем gcd равным k - n / 2 + 1, чтобы в сумме было k. Ну и вывести - 1, если n / 2 > k и отдельно рассмотреть случай n = = 0.
Понял.Спасибо!
Жадность рулит. Первая пара — подбирается большое число и большое число*2 так, чтобы (k-большое число) = количеству оставшихся пар. Каждая оставшаяся пара — любые два взаимопростые числа. можно, например, просто простые числа перечислять. И надо не забыть про разные "особенные" случаи, типа неченого количества чисел, или когда число требуется только одно.
А я думал что в B-шке нужно заранее для каждого числа предпосчитать его делители и забить в вектора, но раз проходит O(sqrt(n)*n^2), тогда я тоже не могу понять отношения авторов.
что это за решение такое, там вроде очевидный n^2logn
upd. а, кажется понял, дп в другую сторону
Можно было просто перебирать делители каждого нового последнего числа до корня.
Наверное, на n^2logn автора и рассчитывали, плохо составили тесты, что ли.
Кстати, 6283465 какую сложность имеет? А то я пока от рекурсии к итерации плоховато перехожу.
это и есть n^2logn
тогда +1 к вопросу ниже)
А можете привести решение? Не понимаю, откуда логарифм.
dp[x][n] = кол-во посл-ей длины n с первым числом равным x.
dp[x][n] = sum dp[y][n-1], y=kx.
то есть одно dp[x][n] считается за M/x, а сумма n/i (i=1..n) как известно == nlogn (гармонический ряд). в итоге и выходит n раз запускается два цикла суммарно за MlogM
Следует внимательно присмотреться вот к этому коду. Интересный факт, что, как сумма гармонического ряда, это в итоге потребляет O(nlogn) времени.
Пример решения:
6274315
Вот этого факта про сумму гармончиеского ряда не знал, спасибо вам и Bugman.
Ну для таких ограничений это нормально. А вот когда для n≤105 слегка оптимизированный n3 проходит, это веселее.
who can explain 4th pretest on B question(div2)?
It was a special case. n == 1 (if k==0 print any positive integer, else print -1)
why the answer is 0? still dont get it
UPD : okay i understand now
C was very nice. I've just finished it now. Big + for the authors. Very nice problems !
Nice problems, I liked them.
Pretests were too strong. I don't complain though :)
Загружать Windows 8.1 за 2.5 часа до начала контеста — плохая примета.
В принципе загружать Windows — плохая идея :)
Вы намекаете, что у меня пиратка? Нет, windows у меня лицензионная и загружал я официальное обновление. Но в случае с пиратским софтом я с вами соглашусь :)
Can anybody help me guess why I have WA on the 7th test from Div1 A ? :)
Link your submission :D :D
http://codeforces.net/contest/414/submission/6287121
DEL
Read the problem statement again, the numbers you print should be >= 1
You should output
1
(or any sufficiently small positive integer) for test case1 0
, not0
. The integers ai must be in the range [1, 109].Omg! :D
Thank you, now I understand the mistake :)
if n=1 and k=0 you should print
1
instead of0
Ну и тестирование...
I thought it's (w — a)/b for the whole contest and couldn't solve it. I noticed it's a multiplication after viewing some solutions :/
I was also stuck for a long time :(
at the first moment i thought like you did...
and then i realized that it's a
.
not-
I need to pay more attention to details.
why is system testing taking so long today?!
Perhaps system test cases of Problem C are so abundant.
Any hint for task D , DIV2?
DP [len][last]
for i = 1 to n for j =1 to k for next= j to k with step j DP[i+1][next]+=DP[i][j]
it can be solved using dynamic programming. if u dont know about it, then first read up on it and solve 3-4 basic DP problems before reading below.
we can assume that
dp[i][j]
be the number of solutions such thati
elements are already chosen, and the last of them isj
.then we will have
dp[i][j] = dp[i+1][j] + dp[i+1][2*j] + ... + dp[i+1][n/j*j]
. and the base case isdp[n][x] = 1
.my AC solution 6275634 uses this idea.
I use the same idea :D, i think it was an easy dp
Combinatorics
Really? Could you explain your solution?
Problem D Div 2 (B Div 1): I should learn a faster language. Even O(KN) on Python still fails the time limit (or I analyzed the run time incorrectly). Most people I asked had only but used C++ or Java or something fast. :(
Is there anyone that tried to solve it in Python or some "slow" language and got accepted?
Sadly, not all problems are solvable using python on codeforces.
You should be cautious submitting problems having O(+1000000), It will most probably time out ... specially using python 3.
Heh, okay, guess I need to get my C++ skills up too. Never thought Python is this much slower than C++. And perhaps note to problem setters: problems that don't force the participants to use a particular language are good. I'm missing those.
It's not about being able to use any language, it's about writing a program that's fast enough. Maybe you could make a Python code work fast enough if you optimized a lot?
My solution of C (div1) has a complexity that makes it possible to pass, but it gave TLE during the contest, yet I'm not saying the time limit should've been larger. It's basically the same thing.
I was under the impression that O(KN) is already fast enough ("hey, only 4·106! Okay, perhaps multiply some coefficient, but it's not that large, isn't it?"), but you have a point too there.
No one did. I found 1 C#, 1 Delphi and about 20 Java.
Delphi isn't "slow".
That's why i said "no one did" :)
I've got AC on Python 3.3
That was easy 6288729
920ms~~ how lucky it is~
6288836
Optimized version, 530 ms
It feels like System Testing Became slow........
I think it is because of the special judge of div1 A(div2 C)...
When can we see our new rates?
just wait a minute~~~ the system is calculating wish your rate get increased~~
I hope so. Thanks. U2 I got to go to school tomorrow early morning so that's why I'm asking:D
now it is updated...
In (Div 2)problem B there was a huge confusion between — and . sign in the equation w.a/b
At first, I thought that the sign was —. Thus, I couldn't explain sample tests. The image of expression maybe not clear enough.
Damn. I solved C in O(n22n) (plus O(n) per query), but my code wasn't fast enough during the contest. I only managed to optimize it well enough to pass around 1 minute after the contest.
6285907, 6288207 — first one got TL during the contest(the only one that passed pretests but got TL on systests), second one passed all system tests in practise mode. The difference is only in one line:(
My solution's complexity is O(n*2^n+mn)
I make a mistake in Div1 D, write a-(b-c) as a-b-c. I corrected this and submitted only to find that the contest was just over!
Посылка во время соревнования выдаёт неверный ответ на 4 тест http://codeforces.net/contest/415/submission/6287526 Стоило сменить тип с longint на int64 (сделал после соревнования): http://codeforces.net/contest/415/submission/6288201
Из-за чего в первом случае выдаёт неверный ответ?
может быть переполнение x[i]*a в предпосл строке
can anyone tell me what is the complexity of my solution to Div2 D problem ? at first i thought it n^2*k because of the loop in the function , i know that loop will not be completed at all , but it loops to n in worst case , when i tried the largest case it didn't take too much time , so i submitted it and it got AC , but i want to know the actual complexity of this solution ? My solution : http://codeforces.net/contest/415/submission/6284352
I think it is n^2logn
Note the following important "equation":
(it can be easily proved).
Now we see that in your code computation of dp[num][counter] takes about operations (and this is done for each 'num' and each 'counter'). Then for each counter computations are quite short:
The counter can have k different values, so overall complexity is .
nice analysis!
i got it :) thaaaank yooou :)
норм пацанам рейтинг не оч подняли
Waiting for the editorial for div1 C and E... I have no idea for these two ....
Maybe this fact will help you in Div1-C. For any x following is true: gcd(x, x + 1) = 1.
He said div1 C, not div1 A.
Oops I thought it was div2 C. Sorry.
Are you sure this helps for div 1 C, not div II C?
У меня в комнате никто не взламывал, и незавалил ни одного систеста.
Round Stats
My screencast: http://codeforces.net/blog/entry/11471
Were constraints in C that big (when O(n log n) (ofc n:=2^n) is expected constraints on CF are rarely higher than 200k) to make O(n log^2 n) exceed time limit? I have written solution in that complexity (I'm so incautious, I thought that this is O(n log n), when this was simply O(n log^2 n) xd) and I think noone will get hurt if those solutions will fit in time limit :P. In my computer on maxtest O(n log n) works 6s while O(n log^2 n) works 7s :P (but in CF difference is significantly bigger). But I won't whine much, I should've think a second before coding :d.
Nice problems, B from div1 can be done better in O( n log k * log^2(n)) with matrix multiplication http://codeforces.net/contest/414/submission/6290524
can you tell me how the idea of this?
Since dp[i][j]=sum{dp[i-1][j'] | j'|j }. Let Vi = (dp[i][1],dp[i][2],...,dp[i][n]) then you can find a matrix that Vi=M*V[i-1]. Thus, you can solve this dp with matrix multiplication. In this case the matrix seems to be in some special form so Horia can store it in O(nlogn) space and multiply two matrix in O(nlog^2n).
I don't know the reason that after system test, my problem A and B are "skipped"!!! (and A,B problems, I just submit one time) Could admin give me a reason??
My Problem B couldn't pass the pretest 4 ... what's the wrong with this? Can anyone faced the same problem?
your solution is not correct, for example with a=2,b=3 and w=2, the answer is
0
not1
w=((w%b)*(a%b))%b; cout<<w;
1 135360 718513035 261734062
the answer is 4435 your program will say it is 600415575
same as mine. try this 1 2 9 5
the answer should be 0
How to solve the problem D in div1
Is the system still pending on testing? I am not able to submit solutions for practice mode.