Привет всем! Совсем скоро начнется Codeforces Round #254.
Главным героем раунда будет клёвый парень по имени DZY. DZY очень любит решать самые разнообразные задачки. К сожалению, не со всеми задачами он может справиться, поэтому вам придётся немного помочь ему.
Традиционно благодарим Gerald за его советы по подготовке раунда, а MikeMirzayanov за создание замечательной платформы для проведения соревнований по программированию.
Задачи готовили FancyCoder и я. Отдельное спасибо пользователям vfleaking, jqdai0815 и lsmll за тестирование задач контеста.
Не упустите свою возможность помочь клёвому парню DZY.
Желаем удачи и удовольствия от решения задач!
Распределение баллов по задачам будем анонсировано совсем скоро.
UPD
Разбалловка для первого дивизиона: 500-1000-2000-2000-2500.
Разбалловка для второго дивизиона: 500-1000-1500-2000-3000.
UPD
Соревнование завершено, всем спасибо заучастие!
Поздравляем победителей!
Победители Div. 1:
Победители Div. 2:
Разбор задач уже опубликован.
Finally :D
A contest announcement,after almost 20days.
It will have a record high of registrants! :D
We hope so.
I can't just believe that I had been waiting a month for this contest.
I wish DZY to be a MERCIFUL guy ..... Everyone Good Luck and Have FUN :)
Sure, he is :)
:)
From my point of view,the problems are all very interesting.Wish you high rating!
PS:DZY's CF handle is dzy493941464.
Hmmm chinese contest. Brave yourselves guys!!
Actually all we need is bravery :))
Brace*
Sounds great! I love cute boys (and girls)!
u love both boys and girls !!! don't confused us about your gender ;) :P
well, some people are just too lovely...
this is the contest after more half month. FUNNY ! :D
the Chinese IOI team 0_0
Brace yourselves, DZY loves desert (http://vfleaking.blog.163.com/blog/static/174807634201422485914893/) incoming...
DZY loves DYNAMIC CACTUS.
20k length…
Link-Cut Cactus??? WTF! So beautiful!
omagad :O! Firstly CACTUS and secondly LINK-CUT? https://www.youtube.com/watch?v=McaV4Ua-QMA (translation ~ "exploding brain") You Chinese are really crazy :P. Hope that I won't see any cactuses in this contest :P.
You had no decrease in your rating chart!
I hope I will get expert in this contest http :D
hope the testing system will testing quick after the contest
Probably won't be able to participate in the contest cause here in Bangladesh its the time for iftar(time to break fasting in the holy month of Ramadan) :( :( BTW best wishes for other participants....
That doesn't prevent you from participating you can put a lot of dates with water beside you :) and continue eating after the contest.
Taking food is not the problem!! The important thing is magrib prayer. Besides there is Isha prayer as well as tarawih prayer which starts within one and half hour of iftar. After all its ok cause, "To get something u have to lose something". Inshallah will enjoy plenty of contests in later days :) :)
How to register this competition?
Registration will be available after 2 Days
http://codeforces.net/contests/444,445
bvd
hey DZY please grow up and try to solve your problems by yourself ! :)
but then we will not have a contest, do you want to wait more for a contest after waiting two weeks? :P
please how i can register to the contest i'm new here
Registration will be open in 3 hours. It always starts 24 hours before the start of the contest.
it's now 24 hours before the start of contest, but the Contests page says that registration for the round will open in 9 more hours only.
Please don't use such silly names; they confuse us.
They make us dizzy.
hehehe yeahhhhhhhhh
Why are we having so few rounds these days? Even TopCoder has only 2 SRMS planned this month :/
Because the Chinese students in preparation for the final exam.//hahaha~
sad its timing clashes with the timing of wimbeldon finals
i hope Federer wins! :)
also, i hope that the Wimbledon final takes more than 2 hrs to finish, then we can watch it after contest is over :)
same here
because of round extension by 5 minutes, maybe we can even watch the first game! ;)
good news. only two sets are over, and both players have won one each.
so we still have a long way to go! :)
yeah ...and hope federer wins this one
hey DZY take it easy !
WARNING: Mathy round approaching!
"DZY loves math xxx"
so he also loves DP, probability, graphs, geometry, data structures (and many more concepts) in addition to just math. ;)
It seems that my prediction was wrong :p
However, round #255 was indeed a very mathy round :D
PS: authors of round #255 is the same as "DZY loves math" series in BZOJ(a Chinese online judge contains only very tough problems)
what round #255? u mean round #FF, right? ;)
I don't have my library currently and my last contest was more than 2 months ago. My question is can I do it as a virtual contest during the same time as the official contest?
PS: For all coders who don't have an online backup for their library, do it ASAP. My laptop's HDD crashed recently and I don't even know yet if the data can be recovered.
I don't think that I notice virtual contest button appear after final system test.
And, what about the unusual contest time??
From the "Urban Dictionary":
DZY
1)Complementary definition of a person, place, or thing..that epitomizes the elements of sheik, classy, cool,or just downright unique.
2) An intensifier
3) Kastration technique (????)
4) Generally used to describe a very cool person
5) Nondescript term that can be used to define anything that is awesome, over the top, and dope.
4) Generally used to describe a very cool person
Now i understand ..
There was a few consecutive contests without delay but I think it's back! Good Luck
Extended by 5 minutes.!
Или я стал тупее, или раунды сложнее..
Вроде все китайские раунды такие
Сегодня вообще был более-менее нормальный раунд. Я бы даже сказал — лучше большинства не китайских. Раунд, в котором каждую из 5 задач решило больше 10 людей, а не популярное в последнее время "а еще вот вам задача Е, которую вообще никто не сдаст, это чтобы вы не забывали, что еще есть куда расти и нет предела совершенству; мне ведь нужно было чем-то занять последний слот в проблемсете".
И действительно сегодня нужно было сдавать все 5, ничего убийственного там не было — в то же время, все 5 не сдал никто, что тоже хорошо. Таблица выглядит интересно, нету банального "1 человек сдал А-Е, 5 человек сдали А-D, 50 человек сдали А-С, 500 человек сдали А-В..." столбиками, на лицо едва ли не все возможные комбинации решенных участником задач:)
И при этом задачи по сложности расставлены более-менее правильно — об этом можно судить по числу АС (хотя не уверен, что здесь не сыграл ключевую роль эффект "надо решать по порядку").
В общем, хороший контест получился)
Pretty tough competition, but great fun!
I liked
B
a lot, though using the randomness of the simple generator felt a bit risky.Was problem
A
greedy somehow?Yes; choose the edge that gives the maximum density. (The induced subgraph will have two vertices.)
Oh...
Because if we have already picked some nodes
vs
and edgeses
, and we want to add nodeu
withe
being the sum of edges fromvs
tou
, then we must have(vs+c)/(es+e) > vs/es
, but that impliesc/e > (vs+c)/(es+e)
so clearly just pickingc
and any node fromvs
would be a better choice.Thanks :D
Exactly. I went on and proved that first before submitting my solution to ensure correctness. :P
Of course, you have to pick the node in
vs
that is connected toc
, but that's why you inspect each edge (instead of any pair of vertices) to ensure the connectivity.for A, we always had to choose two nodes and one edge. adding more edges will make the density lower.
Please can anyone tell me how to do Div2 C ?
new graph consists of 1 edge. :)
OMG I should have thought of that! :(
how to prove it's the optimal solution?
Just above you.
Answer is the best (x[i]+x[j])/c(i,j) where i,j are vertices
how to solve Div-1 B?
also, why my code 7029179 gives WA#9?
del
Problem E uses Inteval Tree (Segment Tree) ?
Oh God, a stupid mistake, in problems B div 1 I use ios::sync_with_stdio(false) but then I use print("%d"). May my code will fail system test because that mistake ?
nope
No, if you used only printf
Contest is difficulty with me !
How solved problem B ?
Put chemicals in order of DFS then caculate danger. I learnt to code DFS when contest is running LOL.
Fast system :D
Good Contest ... Thanks Authors ...
Segment Tree range updates in problem E/Div2 C/Div1 was very similar to UVA12436
UPD : ok ok ... DownVoters i got ... in case colors was fixed this kind of solution would be correct , but in this problem, it wont work ... I hope some days we only DownVote to rude speeches, NOT WRONG IDEAs
Very quickly system testing :D
very fast system testing! :)
I liked the round a lot. C was super nice , I solved it on paper with sets and an segment tree. ( but I'm not sure it's ok ) I got WA on B for something that I thought it works in O(N log N) , but got TLE. Overall , very nice round even though I think I'm going to be div2 after it. :)) Congrats for the authors !
Definitely, fastest system test!
Following my previous blog post on ranking submissions as a collaborative wisdom for picking good reference solutions, i.e. http://codeforces.net/blog/entry/12917, you can now vote your favourite submissions for this contest at:
Div1: http://hiukim.com/cfsubmissions/contest.php?contestId=444
Div2: http://hiukim.com/cfsubmissions/contest.php?contestId=445
Damn it. One character and I'm the first:
What's even more painful is that I wrote right at first, then changed it for testing purposes and then forget to change it back.
Как нормально решать D? Я посмотрел на ограничения до 50000 вместо 100 и целых 3 секунды TL — и заслал перебор за О(N) на запрос.
Для начала выкинем одинаковые запросы (это важно). Потом на каждый запрос отвечаем за , где A — количество вхождений первой строки, а B — количество вхождений второй. Если поменять местами в правильном случае (так, чтобы A ≤ B), то получается .
А чтобы в запросе получить этот логарифм — хранить все вхождения каждой строки в каком-нибудь сете?
Спасибо)
Вероятно, у меня примерно такое же решение, только ответ на запрос за A+B (два указателя).
Нет, просто бинпоиск по отсортированному вектору. У меня он получается отсортированным автоматически.
Действительно) Update'ов ведь нету, можно все по векторам раскидать...
Двумя указателями не должно проходить по времени. Смотри http://codeforces.net/blog/entry/12923#comment-176810
На таком работает 3.7. Хоть это и TL, но еще не самый кошмарный вариант.
Во-первых, вхождений а не так уж и много, ~25к; во-вторых, из-за того, что буква а встречается очень часто — подстроки в запросах часто повторяются, и различных запросов получается значительно меньше 100к.
Для строки, в которой первые 2/3 — символы а, а дальше рэндом, и запросы вида 1..4 буквы а + рендомная подстрока длины 3..4 из хвоста — работает дольше 10 секунд:(
А почему получается такая оценка? (Я про корень).
На запросы, в которых оценка, очевидно, не хуже, поэтому их сразу откидываем.
Теперь в каждом запросе у нас . Заметим, что различных подстрок, каждая из которых встречается в строке длины N хотя бы раз не более . Применим немного амортизационного анализа: будем считать время выполнения не каждого запроса (которое состоит из X запусков бинпоиска, где X — количество вхождений одной из подстрок), а для каждой подстроки S считать, в скольки запросах мы по ней итерируемся и пускаем один бинпоиск. Так как у нас может быть не более различных подстрок в паре с текущей (одинаковые запросы мы давно выкинули, а всего часто встречающихся различных подстрок не более ), то получаем оценку в запусков бинарных поисков по массиву длины не более N.
Спасибо :)
Я еще добавил оптимизацию, что если длины отличаются менее, чем в логарифм раз, то работать за сумму. Интересно, убирает ли это лог под корень?
This bug has costed me 100 points.I have clicked once submit.
I wrote lots of code for C(div 2). Than I recognized we just need two nodes and an edge. :(
My code got wrong answer on pretest 5 div2 A. I see the test case but I think my output is also correct. Can someone check it for me please? http://codeforces.net/contest/445/submission/7032620
On the second line of your output, you have two B's next to each other.
Oh I see. Thanks
Next time you should take a look at checker comment before asking such questions
I did but I was such in a hurry to find the wrong one and angry because of not being accepted, so I didn't see it. You're right. Thanks for your advice
the fourth last line, the last two characters are the same.
"wrong answer Two same chessmen stand in adjacent cells 2, 27 and 2,28" . Check those places, BB occurring there.
will there be any solutions posted?
Editorial will be posted very soon. BTW,the contestants' solution for Div1 E was unexpected to us...Our solution was far more slower,that's why n is only 3000
Anyone who tried to exploit the random generator in 1B? Many solutions (including mine) depends on randomness. Problem statement blocked the unique fixed point, but there might be some small cycle which can hack these kinds of solutions.
Our intended solution do depend on randomness,so we blocked that number.
Is there any solution for arbitrary permutations (better than straightforward n^2)?
Check it out in another thread
Oops, I forgot people might try to hack that. I was relying on the problem setters being nice :-)
If there is a 1-cycle, probably there are also cycles of most other lengths?
No, there are one 1000000006-cycle and one 1-cycle.
Seems like authors considered such hack :-
Any proof for that?
1e9+7 mean nothing, brute it.
I don't know if
% (i + 1)
could help create some "cool" sequence, likely not.You can get the explicit formula of this sequence, and you will find 37 is the primitive root of 10^9+7, so the cycle's length is 10^9+6.
This is very interesting. So actually the 10007 term was unnecessary and nearly half of all numbers less than 10^9+7 would have worked as factors. At least these would all have given a 10^9+6 cycle.
http://mathworld.wolfram.com/PrimitiveRoot.html
How to get on the main page after the contest without actually participating. =)
I have used 4 Segment tree to get AC problem C (after the contest). Does anyone have better solution? Thank you.
waiting for editorials...
How to solve div2D? FFT?
A Div2 was harder than a usual A Div2
English Editorial has been posted!
interesting problem set, I wrote complicated solutions for C and E, and got very simple solutions after reading subscriber's code, cool!
3 bytes far from all clear orz.
Very nice round. I liked the problems even though i only managed to solve 1. Div. 1 A proved to be a nice revelation. I got the idea by thinking back to when i used to play online shooters when I wanted to maximize my kdr (Kill-Death Ratio). Say my current kdr was K/D and in a match i'd manage to get k kills and d deaths. Now if k/d > K/D then (K+k)/(D+d) > K/D and my kdr would grow or it would fall otherwise. The same thing applies to the problem at hand.
The TIme limit for problem C should have been 3s. My algo was correct (used sqrt-decomposition) but I had to reduce the size of each partition by a constant amount to get it accepted.
What's the problem then? It's absolutely OK that some implementation details matter a lot, imho.
You can see the country wise standings for the contest here. In case you want to report bugs / suggest features, kindly use this blog.
В D слабые тесты. Это решение 7032235 валится по TL следующим генератором
Сдал в B какую-ту глупую жадность, думал, что завалится, а в C сдал вообще бред, мне казалось, даже претесты не пройдет. Ан нет :)
Round Stats
Div1-B can be solved without regard to randomness in time. See 7031500
I'm curious why do you use integers in your BitSet? For example my implementation with longs 7040099 works like 1.5 times faster than same with ints 7040106.
It seems to me that and O(n2) are same, therefore there is no reason to write 32 in the denominator.
Formally, they are, but in this case, the /32 factor is used to denote that the constant factor will be that much smaller.
Still my notation leads to a little bit better understanding of actual solution timing, isn't it?
How to solve div1 C using segment tree ?
"всем спасибо заучастие". Пофикси, пожалуйста.