Блог пользователя vovuh

Автор vovuh, история, 8 лет назад, По-русски

<copy-pasted-part>

Привет! В Aug/24/2018 17:50 (Moscow time) начнётся Codeforces Round 506 (Div. 3) — очередной Codeforces раунд для третьего дивизиона. В этом раунде будет 6 или 7 задач, которые подобраны по сложности так, чтобы составить интересное соревнование для участников с рейтингами до 1600. Наверное, участникам из первого дивизиона они будут совсем не интересны, а для 1600-1899 покажутся простыми. Однако все желающие, чей рейтинг 1600 и выше могут зарегистрироваться на раунд вне конкурса.

Раунд пройдет по правилам образовательных раундов. Таким образом, во время раунда задачи будут тестироваться на предварительных тестах, а после раунда будет 12-ти часовая фаза открытых взломов. Я постарался сделать приличные тесты — так же как и вы буду расстроен, если у многих попадают решения после окончания контеста.

Вам будет предложено 6 или 7 задач и 2 часа на их решение.

Штраф за неверную попытку в этом раунде (и последующих Div. 3 раундах) будет равняться 10 минутам.

Напоминаем, что в таблицу официальных результатов попадут только достоверные участники третьего дивизиона. Как написано по ссылке — это вынужденная мера для борьбы с неспортивным поведением. Для квалификации в качестве достоверного участника третьего дивизиона надо:

  • принять участие не менее чем в двух рейтинговых раундах (и решить в каждом из них хотя бы одну задачу),
  • не иметь в рейтинге точку 1900 или выше.

Независимо от того являетесь вы достоверными участниками третьего дивизиона или нет, если ваш рейтинг менее 1600, то раунд для вас будет рейтинговым.

Спасибо MikeMirzayanov за платформы, помощь с идеями для задач и координацию моей работы. Спасибо моим очень хорошим друзьям Михаилу awoo Пикляеву, Максиму Neon Мещерякову и Ивану BledDest Андросову за помощь в подготовке и тестирование раунда.

Удачи!

Также хочу сказать, что участники, намеренно отправляющие неверные решения и взламывающие их после окончания соревнования (пример), не будут показаны в таблице лидеров по взломам.

</copy-pasted-part>

UPD1:

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

Rank Competitor Problems Solved Penalty
1 problem_destroyer420 5 209
2 syh0313 5 225
3 VinceJudge0 5 230
4 SaIah 5 234
5 EctoPlasma 5 241

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

Rank Competitor Hack Count
1 halyavin 506:-92
2 antguz 121:-20
3 Anguei 50:-11
4 taran_1407 41:-1
5 zdw1999 41:-2
6 applese 40

Всего было сделано 1217 успешных взломов и 926 неудачных взломов!

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

Problem Competitor Penalty
A i_f_y_m 0:03
B SaIah 0:03
C SaIah 0:13
D _kawaii_neko_ 0:17
E syh0313 0:43
F iamunstoppabIe 0:19

UPD2: Разбор опубликован.

  • Проголосовать: нравится
  • +126
  • Проголосовать: не нравится

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

just have strong pretests because then only hacks make sense

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Will be original cf round on September 1st?

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How are you going to detect the people who hack solutions having some if statement to remove them from standings table? Is there some algorithm?

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +60 Проголосовать: не нравится

»
8 лет назад, скрыть # |
 
Проголосовать: нравится -33 Проголосовать: не нравится

move contest time 3 hours later .. this time is not good

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится -66 Проголосовать: не нравится

Well Well Well

»
8 лет назад, скрыть # |
 
Проголосовать: нравится -26 Проголосовать: не нравится

Warning, this is a joke, don't feel bad if you are div 3.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +35 Проголосовать: не нравится

DIV3 ROUND! It's time to challenge your coding skill together with coding speed!

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

coming expert , i wish .

»
8 лет назад, скрыть # |
 
Проголосовать: нравится -29 Проголосовать: не нравится

»
8 лет назад, скрыть # |
 
Проголосовать: нравится -18 Проголосовать: не нравится

Hope there will be strong pretest. Don't want the codeforces changes to the hackforces. Thank you very much.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hope that I will become expert after this contest. :)

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +27 Проголосовать: не нравится

Why the 15 minute delay ?

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Delay :(

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

+15 минут? Серьёзно?

Я даже страницу обновил за две минуты до начала, и переноса ещё не было! БЕСИТ!

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +39 Проголосовать: не нравится

The Wait!!!

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

00:00:15 -> F5 -> 00:15:00

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +33 Проголосовать: не нравится

Someone please make a Codeforces Delay Predictor -_-

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +75 Проголосовать: не нравится

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

how to solve A?

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится -8 Проголосовать: не нравится

Before:00:00:15 before start, Now:00:08:00 before start, Will-be:This round will be unrated :)(JUST JOKING)

»
8 лет назад, скрыть # |
 
Проголосовать: нравится -17 Проголосовать: не нравится

Hackforces, Delayforces, Memeforces, Mathforces, who's next??

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +24 Проголосовать: не нравится

Is it Div 3 contest? I think it's too difficult

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +4 Проголосовать: не нравится

<copy-pasted-part>

<copy-pasted-part>

.......ANNOUNCE.....

</copy-pasted-part>

</copy-pasted-part>

You may do in such way, we'll understand

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +1 Проголосовать: не нравится

I am getting wrong answer on test 1 problem A and can't even figure out why. :'( edit: figured

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve problem D ?

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится

this is not div.3 contest

  • »
    »
    8 лет назад, скрыть # ^ |
     
    Проголосовать: нравится -58 Проголосовать: не нравится

    i hate vovuh

    • »
      »
      »
      8 лет назад, скрыть # ^ |
       
      Проголосовать: нравится +45 Проголосовать: не нравится

      This is sad :(

      • »
        »
        »
        »
        8 лет назад, скрыть # ^ |
         
        Проголосовать: нравится +13 Проголосовать: не нравится

        Although I found the problems harder than the last div3 contest, I still enjoyed it! At the end of the day, I'm sure I'll come out of this round knowing more than I did before(once the editorials are out of course xD)

        So a relatively difficult div 3 contest(compared to past div 3 contests) isn't necessarily a bad thing :)

      • »
        »
        »
        »
        8 лет назад, скрыть # ^ |
         
        Проголосовать: нравится +13 Проголосовать: не нравится

        Vovuh why not increase the time limit to 2.5 hours because i think most probably div3 contests have a large fraction of people who always thinks that if i could have given 15 more minutes i could have definitely done one more problem(i m one of them).. i mean this just boosts up the confidence and belief.. this suggestion may be immature but i feels at least 2.5 hours should be given for 6 problems to do justice with the contest,those who solves first will have better rank whether the time is 2 hours or 3 hours.. although these contests are awesome always if one try to solve problems before or after contests .

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I try to solve Problem B with a solution of upper_bound(a[i]*2) but fails. How to solve this?

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In problem F, what does this mean : "all tiles of at least one color would also form a rectangle." ?

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

What is pretest 4 for B?

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Welcome to Codeforces Round #506(Div.2)

Edit: only A isnt a Div.3 A problem.. B is easy but the trap in reading the statement is just so unexpected

other problems are Div.3 problems

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится -29 Проголосовать: не нравится

pretest 6 in A. I want to know that sh*t and yea, i still hate vovuh and his friends who always writes shity contests. (I'm not afraid downvotes)

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to handle the case in D when 2 | k or 5 | k. Is there an easy way to do this than to calculate modulus for all possible factors of k which still aren't coprime to 2 or 5

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

What's pretest 7 on C? I can't figure out where I screwed up.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится -7 Проголосовать: не нравится

There should not be hard deadline time to end the contest, atleast 20-30 seconds extra should be given, given the initial load on the system. I missed the D by 1 second today.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

What the wrong answer test 17 in the problem D ?

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +5 Проголосовать: не нравится

I solved C with Segment Tree, is there other topics solve this problem? because I feel that it is easier than SegTree when I saw someone solved it quickly.

»
8 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

can someone plz tell me what is wrong in this approach for E? A node ( > depth 2) may be reached through child or parent who has a direct edge or there is a direct edge to this. SO, a) if i want to reach this node from parent, then for each child there must be a direct edge or any of their children must have a direct edge. b) if i want to reach this node from children, any one can have a direct edge and others can have direct edge or their children can have a direct edge.
c) if i have a direct edge to this node, then i can take the min( a, b, c);

Can someone plz tell me what is wrong here, here is the link, https://ide.geeksforgeeks.org/Nn0MdojmeD

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +2 Проголосовать: не нравится

Will an O(10 * n * logn) solution pass systests for problem D? Link

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Can someone tell me about solution for problem E ?

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +5 Проголосовать: не нравится

Seems like problemsetters have been missing how problem A should be :D for the last few contests.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Am I the only one who misread the problem statement of B? I guess no.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

problem F, finished in 10 mins after contest :((

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to Solve C ?

  • »
    »
    8 лет назад, скрыть # ^ |
    Rev. 3  
    Проголосовать: нравится 0 Проголосовать: не нравится

    The intersection length of n segments is min R - max L (invalid if it's negative), so just ignore each segment and evaluate length, i used multiset to insert/remove in O(log n). I'm doing this for n segments, so the total complexity is O(n log n).

    Code: 42096347

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

what's wrong with 37'th in problem F ?

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Nice contest : )

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

for me the statement on b,c are very confused after explanation b become clear and I'm solve it, c after contest solve it its easy but not clear with this statements.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Is it possible to share ideas of hacks with other people before the end of the hack phase? Does it violate the rules?

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

Honestly, when I saw problem A, I thought for a second if it is really Div 3 (and I haven't passed A). It was quite good, except they were a bit too hard for newbies (like me), and frankly some problems were more suitable for Div 2, or even Div 1 instead. Still, I appreciate the hard work of today's contributors for thinking up the problems!

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

is it a rated contest or not ? also i can't understand the General announcement, which say (We will publish separate standings for trusted participants after the contest.)

:) :) :)

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

 I wish I could code this fast XD. Parallel Programming :P

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

seems like another halyavin day , nearly 450 hacks . wow again .

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +96 Проголосовать: не нравится

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Did anyone solve B using dp and implicit segment tree? I guess it's an overkill, but to me it seemed better than to guess that the solution is always a continuous segment.

  • »
    »
    8 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I guess that this solution would be the best if the sequence was not in increasing order.

  • »
    »
    8 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    You can try to prove it during the contest. Just imagine you have already some subset, with the last element at index i (the array is sorted, and all of the elements with indexes > i are bigger). Now you want to try to add another element to this subset, suppose you added element j (j > i+1). Now you can see, that if element a_[j] <= a_[i]*2, the same applies to other elements in an interval [i+1, j-1] and it's always worth it to take smaller element. But why? Consider x as the smallest integer in the subset we consider at the moment. It's easy to see we want to minimize the largest integer in our subset (lets name it y), so 2*x >= y. This strategy applies to every element we consider in our subset — concluding — our subset will always be contiguous (if the array is sorted). Please correct me if I made some logical mistakes.

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

in problem B 2 1 2

how is the answer 2 ?

i knew that the statement contained <= but i thought that it is <

how isn't there any pretest to check this ?

»
8 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится +1 Проголосовать: не нравится

Just curious, how could someone (or to be precise, antguz) confidently hack my O(10 * n * log(n)) solution of problem D to successfully give a TLE verdict?

My hacked solution: 42049909

My re-submitted one (with some slight optimizations, still TLE on other similar tests, which gave the conclusion that my solution ran at somewhere around 2.5-3s): 42071241

  • »
    »
    8 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    I had the very same issue as you so I thought of helping. TLE will go if you use unordered_map. Link to your submitted solution.

  • »
    »
    8 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +8 Проголосовать: не нравится

    I think the issue is not in usage of map instead of unordered_map, but it is in that you used the operator [] when you wanted to add values to the result.

    Instead, you should check if a key you want to add its value was already existed in the map by the member function count(), and if yes, then add the value of that key to the result.

    Because when you use [], if the key in [] is not existed yet, this operator will create it, so the size of the map will increase by one, and so on. So, the time needed to access the map will also increase with the increasing of its size, thus you will get TLE.

    Check my submission for more details.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone please point out why my code is giving TLE for problem D? I have tried all the optimisations I could think of at my level. It would be really helpful if someone can help me out here. Thanks in advance !!

»
8 лет назад, скрыть # |
Rev. 5  
Проголосовать: нравится 0 Проголосовать: не нравится

Are there any better solution in problem B? I use dp and RMQ to solve this problem, but I think it's too complex for the problem B in div 3 contest :((

I use F[] with the meaning that F[i] is the answer ending at i. I use lower_bound to find the minimum value that more or equal A[i] / 2 (called j), than find the maximum value of F from j to i — 1.

P/s : If the array isn't in increasing order, what should we do?

Edit: If the problem like this : find the maximum length of a subsequence ( by delete some elements ) (like LIS) but a[i] <= a[i-1] * 2 in this subsequen. what will we do?

eg:

Input n = 3 array[] = {2, 1, 4}

Output 2 ( 1 and 4 )

  • »
    »
    8 лет назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    You can traverse greedily in O(n): find the longest increasing subset that the criterion aij + 1 ≤ aij * 2 holds true.

    So, of course, if the array isn't sorted yet, we can just sort it beforehand — nothing special.

    • »
      »
      »
      8 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Thank you.

      If the problem like this : find the maximum length of a subsequence ( by delete some elements ) (like LIS) but a[i] <= a[i-1] * 2 in this subsequen. what will we do?

      eg:

      Input n = 3 array[] = {2, 1, 4}

      Output 2 ( 1 and 4 )

  • »
    »
    8 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Excluding the last element (i.e., the biggest), you can just calculate the length of the largest interval I = [L,R) such that I[R-1] <= 2 * I[R-2] holds.

    So L starts at 0, R at L+1, keep increasing R until the property I[R] <= 2 * I[R-1] is false. Then reset L = R, and repeat the process until R >= N. After doing that, the answer is the max R-L difference you've found in this process. There is one corner case: N = 1.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Freakin' A Again >(

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

Мне кажется, для задачи D ограничение по времени стоило бы немного увеличить, потому что те люди, которые решали эту задачу за O(10 * n * logn) получили взломы в виде ограничения по времени. Несправедливо, ибо это же не лобовое решение, и оно, как мне кажется, имеет место быть в ряду АС.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In problem D, using unordered_map gives TLE while submission with map gets accepted. I can't figure out why.

http://mirror.codeforces.com/contest/1029/submission/42051858 (AC code)

http://mirror.codeforces.com/contest/1029/submission/42063201 (same code with unoedered map)

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

CodeForces is the worst. Solution 1 Solution 2 Both solutions are the same. So during system testing, my correct solution fails only because of the load on CF server, which is basically CF's fault. So now I've to pay for it to settle for a worse rank.

And I know even tagging MikeMirzayanov won't do anything because these kinds of crap has happened before and nothing was done.

  • »
    »
    8 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +24 Проголосовать: не нравится

    Your solution was already borderline. Also, time is actually calculated by the no of clock cycles your solution takes to finish execution, and not wall time, so I don't think it has anything to do with server load. +-100ms in similar code execution can be expected

    • »
      »
      »
      8 лет назад, скрыть # ^ |
      Rev. 2  
      Проголосовать: нравится 0 Проголосовать: не нравится

      Yes I know it was borderline. It had passed test 7 in 2.8 s during the contest. But I think it's the server load only because I've read more such cases in a few contests held earlier and my solution to D also took more time to execute than it took during the contest.

      In general I have observed that borderline solutions fail only during system testing leading me to believe that load during system testing is the only reason, because otherwise they still pass.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

When will ratings get updated?

»
8 лет назад, скрыть # |
Rev. 5  
Проголосовать: нравится +1 Проголосовать: не нравится

I don't know why this submission for problem C 42040684 got hacked and then I again made the submission 42076792 with the same code and it passes all the tests, this seems to be a serious issue, as its the fault of the system which gives different execution time for the same solutions and unexpected time penalties. I think the hacked test case is the last one #71 ..Plz have a look at it.....

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Was the time limit too strict for problem D?

42055423 Uses unordered_map and gets a TLE; 42076582 Uses cc_hash_table and gets an AC.

Time complexity of both solutions is O(11*N).

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

Problem D makes me very sad.

I write a O(n * logn * 11) then get a TLE on test 28.

I make some optimization to O(n * logn * 10) then AC.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

When will ratings change?

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve problem D?

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

when will the editorials be out??

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

The same code for Problem D running on G++11 gives TLE on test 50, and with G++14 gets Accepted. I don't think such stiff time limits give fair assessment.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve D? just an idea will be helpful

  • »
    »
    8 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Assume you are at a point ai and assume ai is l digits long. Then ai gives a solution when there exists aj in the array with the property 10l × aj + ai. has a remainder 0 when divided by k. With a bunch of precomputing you can find how many ajs have this property. However you have to be careful to remove the case when i = j. Also for the precomputing using 10 maps or unordered_maps for each of the powers of 10 you need seems to lead to TLE. You can avoid this issue by instead sorting and using a binary search.

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

UPD: Sorry I got it, the answer of my idea is 2 + 2 * (a + b). So, never mind.

In F, is there any statement in the statement denys us from coloring the tiles as a rectangle with dimensions (1 * (a + b)), so the answer will be a + b + 2?

Because in the given samples (and all testcases I guess), the answer with my idea is always less than or equal to the answer from these samples.

»
8 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится +54 Проголосовать: не нравится

For Problem D — TLE issue

People here find the Time limit strict ( even I did ) , but actually it isn't that strict. The only issue while using map which almost everyone is facing is :

If u simply do ans += mark[digits][requiredmod]; then even though that required mod doesn't exist in the map, then also it will be added to that map and now the size of the map = (actualsize+1), and if you do this n*10 times the size of the map would increase and therefore the time to search as well

So what u need to do is first search whether that element is present in the map and then add it to the answer, as shown below :

if ( mark[digits].find(requiredmod)!=mark[digits].end() ) ans += mark[digits][requiredmod];

This is the only difference in my accepted and TLE solution.

Accepted Solution : http://mirror.codeforces.com/contest/1029/submission/42081763 TLE Solution : http://mirror.codeforces.com/contest/1029/submission/42082128

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +13 Проголосовать: не нравится

DP Solution for Problem E

DP state : (node, cur, par)

node -> The index of the node

cur ( 0 or 1 ) -> Whether the given node either has or is supplied with an extra edge connecting it to the root

par ( 0 or 1 ) -> Whether the parent of the given node either has or is supplied with an extra edge connecting it to the root

Now 3 cases arise :

cur:1 -> sum over all children {min(solve(child,1,1) + 1, solve(child,0,1))}

cur:0 par:1 -> In this case the current node has a path of length 2 to the root by going to its parent and then from parent to the root. sum over all children {min(solve(child,1,0) + 1, solve(child,0,0))}

cur:0 par:0 -> This is the most important case. Main Point : This node doesn't have a path of length atmost 2 to the root, so it has to make use of ATLEAST 1 of its children*

Case 1: Leaf node -> You need to make an edge straight from here to the root. ans =1

Case 2: Internal node -> Select atleast one child from which you will make a direct edge to the root. Code for this :

vector < pii > vec;
int sum = 0,idx = 0;
for ( auto child : adj[node] )
{
    vec.pb({solve(solve(child,1,0)+1,solve(child,0,0)});
    sum += min(vec[idx].first,vec[idx].second);idx++;
}
int ans = INT_MAX;
for ( auto child : vec )
    ans = min(ans,sum+child.first-min(child.first,child.second);
»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For E does greedy approach like this work? Take any leave. If its distance to root in the input tree is <=2 we are done for this leave. Else connect parent of this leave with the root and delete this parrent and all his sons and his father from the tree.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Could you please publish a tutorial for the contest !

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

Can I get a tutorial for this contest?

»
8 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится

Could you please publish the results, the best hackers and the tutorial?

And we know, the best hacker is halyavin as usual.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

It's sad having problem E with all tests except samples n = 200000. Have WA8 and don't know how to debug)

»
8 лет назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

I think the ranklist has something wrong.

Such as the participants VinceJudge0's solution for D was failed during the system test, but the ranklist shows that he/she solved 6 problems. Is this a bug?

vovuh Please check it. :D

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

42038360 He use “for(int i=1;i<=floor(sqrt(a)+0.5);i++)” .He got TLE on my computer because calculate sqrt() many times is much slower than calculate it at first. But codeforces maybe use -O2 -O3 or something and he Accepted. :(

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone tell me why I'm getting TLE in D? my submission

I read all the comments but can't figure it out.. :(

»
8 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Why does this TLE?

Can't find the reason.....

The time complexity should be O(n*log(10n)) (Correct me if I'm wrong) http://mirror.codeforces.com/contest/1029/submission/42107686

»
8 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

you should probably change the time limit of Problem D.

»
8 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hope that the contest page doesn't show "starting in 15 minutes" after 3 minutes