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

Автор Denisov, 6 лет назад, По-английски

Hello, Codeforces!

We (Denisov, karavaiev, perekopskiy) are glad to introduce to you Codeforces Round 660 (Div. 2), which will happen on Jul/30/2020 17:35 (Moscow time). The round will be rated for the participants with rating lower than 2100, although higher rated users are more than welcome to take part out of competition.

Huge thanks to those who helped make this round possible:

There will be 5 problems and 2 hours to solve them.

We really hope you enjoy our first contest!

UPD: Here is the score distribution:

750—1000—1500—2000—2750

UPD: Editorial is published!

UPD: Congratulations to the winners!

Div. 1:

  1. neal

  2. Um_nik

  3. heno239

  4. jiangly

  5. dreamoon_love_AA

Div. 2:

  1. okikust

  2. SpatialMovement

  3. laralalala

  4. KD-Tree

  5. Mai_madarchod_hu

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

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

Piccy.info - Free Image Hosting!

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

if(count(red color) >= 5) {Contest go pew pew over the brain}

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

Фанаты папича оценят этот раунд

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

Солью задачи, оплата киви/сбербанк, за пробником в лс

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

Удачи с вашим первым раундом!

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

The contest with 5 problems are terrible but nice.

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

I think this looks much better (the presence of many colors in the contest announcement). I hope this will help and the contest will be balanced this time.

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

Five grandmasters as testers... hahahahhahahaha what a great opportunity for another -100 rating drop

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

5 questions means another DIV 1.5 contest.

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

Back to back DIV 2 contests, perfect for my rating to enter hell. ;--;

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

2 rounds back to back. And the next round (#661) is 10 days away. Wow. Sure 10 days will be useful for gaining back the trust in self.

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

they have started making difficult contests to ease the system

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

5 red testers ===>>> great pretests and less heartbreak at system tests.
7 testers of lower levels ===>>> balanced round.
===>>>
5 red testers && 7 testers of lower levels ===>>> balanced round with great pretests and less heartbreak at system tests.

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

I miss the days when we discussed if we want more Div3 or more Div4 contests :/

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

hope to give an official submission this time . Left round 657 and 659 cuz can't do anything bout that xD

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

There will be 5 problems and 2 hours to solve them.
Surely the difficulty of contest will be high. After 2 back to back unrated contests due to long queue codeforces has come up with brilliant idea.
Less questions --> higher the difficulty --> less submissions--> no queue --> no unrated round --> No questioning on CODEFORCES PLATFORM.

Forget about Division-3 Rounds Codeforces is trying to make even Division 2, a new DIVISION 1.5.

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

wait , no div3 or div4 ?

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

Hoping for a good contest for me so that i can get out from the bad time i am spending right now.

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

Hope for a good and balanced round. Testers from specialists to grandmasters provide hope for low to high rated participants for being round of their type. Hoping for good positive in this round.

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

I wonder why does it take time to reveal the scoring distribution ?

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

Now, we have score 750 for problem A. Let's wait for another challenging disaster.

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

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

750 points for A? Solid A I guess

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

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

Удачки с первым контестом, жду с нетерпением чтобы начать писать!

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

I am getting a runtime error with the message "Exit code is -1073741819" again and again for educational round 92, problem B. I tried my best but does not understand its causes. Please tell me what could be reason for this error. my submission is https://mirror.codeforces.com/contest/1389/submission/88348466

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

I am quite concerned about the score distribution of this contest. Is it too difficult for members with a rating below 1500?

And over 1500, I think it's okay

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

Does anyone know why atcoder is not having ABC for last couple of weeks?

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

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

Is it like people aren’t interested in this round? By seeing only 484 upvotes which is less than the normal upvotes for a Div2 round. Can anybody please share the reason for the same ?

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

How is it decided that an incorrect submission will result in -50 (in the score) or -10 minutes? Or is it just up to the creators?

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

    -50 points, as the problems each have points, if they didn't like in educational round or div3 then -10 minutes

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

    From my knowledge they are different rules. Usually educational rounds and div3 rounds are held on extended ICPC rules, which result -10 minutes. Others result in -50 in score.

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

    As far as I know, Educational rounds and Div.3 rounds are not score based, i.e., in those rounds only the number of solved problems matter. Since those rounds do not involve score, hence they have Time penalty for incorrect submission. On the other hand, Div.1 and 2 are scores based, i.e. each problem has a score associated to it, hence they have Score penalty for incorrect submission.

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

we are friends now! hello, friend! [user:Mike!Mirzayanov,2020-07-30]

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

too op :-(

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

All the best friends!!

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

Could codeforces consider weekend contest? I have conflicts on the weekdays (unless it's before 6 AM PST or after 5 PM PST). I'm pretty sure other people have more time on weekends too.

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

Как же смешно читать условия задач, если знаеш рофлы про Пукича и его детство. Спасибо тем, кто писал условия. RoflanSpasibo

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

pic1.png pic2.png

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

I submitted my solution of problem A at 0:15. And after submitted my solution to problem B I tried Problem C but couldn't do it.. Then I was feeling kind of bored so I resubmitted my Problem A and B but in Kotlin as I am learning this new language from the last couple of days.. As soon as I submitted it, it added time penalty and my rank decreased.. Why did this happen ?? MikeMirzayanov please can u help ..

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

Who is uncle bogdan I wish I am as talented as him

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

Well even if the contest ended up being speedforces but I still really enjoyed thinking about C,D & E. They seemed really interesting and I can't wait for the editorial. Thanks for the interesting round!

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

gradient(difficulty change from D to E) = +infinite

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

Is topological sort wrong for problem D? I am adding edge from x->b[x] if a[x] is positive, and b[x]!=-1, and the opposite edge if a[x] is negative! Please tell me whats wrong in this?

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

help me with C after the contest

  • »
    »
    6 лет назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится +1 Проголосовать: не нравится
    Explanation to problem C
»
6 лет назад, скрыть # |
 
Проголосовать: нравится +19 Проголосовать: не нравится

First reaction after reading C: bruh

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

is it rated?

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

After making silly implementation mistake in B I thought myself as cabin boy Kostya.

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

Irritating B, as all B's should be

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

Thanks for the round!

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

Nice contest, great problems. I really liked how you put the background stories at the top so we could simply ignore them. Although there was a huge difficulty gap between B and C (causing speedsolvers of A and B to get a high ranking), I think the problems were good overall. Hopefully pretests are strong (don't let me down), and I'm still very thankful that you included 36 in the samples for A (I'd probably get WA on pretest 2 and be scratching my head if you didn't)

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

Your text to link here...

whats wrong with my code of second problem please help??

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

Wasn't a lot of problem B solution given by the example input.

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

Seems like yet another rushed contest to maintain schedule.

(With all due gratitude to the the writers) Urging organizers to please be patient for decent enough problems for a well balanced set before arranging a contest.

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

lol, C is more difficult than D and E

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

For me C and D have same difficulty

I got the solution of D but don't have enough time to implement it.

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

Whay is the solution for C?

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

    Try to solve a simpler version in which all cities are in a straight line. The intuition there carries forward to the general tree case. Its a good dfs question.

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

    Do a bottom-up dfs and for each node i, 2 conditions must be satisfied

    1. You should be able to divide totalPassing = (p[i]+(sum of p[u] in whole subtree)) to "happy" and "unhappy" to get the required h[i]. This can be done be simply checking if totalPassing%2==abs(h[i])%2.

    2. Total number of happy in all of its children should be greater than the "happy" calculated from h[i]. This is because, if a node as n happy people then everyone in the subtree can have at max only n happy people.

    If one of them is false for any node, answer is "NO"

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

      also will this hold : |mood[leaf]|=p[leaf] ? (|x| is absolute val)

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

        Yes, why not? |mood[leaf]|=p[leaf] means that for any leaf, all its inhabitants are either all unhappy or happy

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

          Yes got it, so help me here alright, We get the node(call it v) which is parent of some leaves and leaves only (let it be parent of x leaves), so this must hold :

          people[v]=| mood[v]- (mood[leaf1]+mood[leaf2]+...+mood[leafx]) |

          Now my question is what about the other nodes, I am getting confused here on writing the people equation for other nodes.

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

            That equation isn't correct. Just look at it this way, Total number of people passing a node is the total number of people living in the whole subtree.

            First of all you need to be able to divide this total into the required h[i]. Ex- If the total people is 10 and and h[i]=4 then happy people is 7 and unhappy people is 3.

            NOw some of these people are gonna pass down into the subtree. Here is the important part, The 7 happy people can be converted to unhappy people but the 3 unhappy people cannot be converted back to happy. So here is where we need to check the condition that

            Total number of happy passing a node >= sum of happy people of all everyone in the subtree

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

Is 3rd pretest for problem D — 3rd sample test case?

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

Nice problems. I think this round is somewhat similar in difficulty to old div 2s and I like it. Been a while since I struggled with C.

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

You are lost when you get WA on C. Like how can you debug this. How can you generate test cases and see which works. I am lucky to debug C

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

How to solve problem D? Would topological sort fail?

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

Is E to binary search for most vertical vector?

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

Does problem D involve topological sorting?

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

I dont have idea how to solve D, but guide me if what im thinking might be correct,(if it's related to graphs? )

So, we have a directed edges with few nodes with negetive value and other with positive.

My approach:

1) find cycles in graph.

2) for remaining nodes(which are not in cycle),

2.a) if it's positive, add the value to the node it is pointing to,

2.b) if it's negetive, add it in the final sum, i.e only once?.

3) for every cycle begin counting the sum, from node which has highest value of Pi

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

Hey can someone explain me, why this sample test case is NO??

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

    The mood in city 3 is 4, but it has 7 people in it.
    4 % 2 == 0 but 7 % 2 == 1.

    Edit: The mood of a city must have the same parity as the number of people who pass through it.

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

    the parity of the happiness index and the number of people going through that city should be same. for example if there are 4 people going through a city the happiness index can be 4,2,0,-2 or -4 but it cant be 3,1,-1 or -3. In your case for city 3 number of people is 7 that is odd therefore happiness index cant be 4 as its even

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

Problem C was quite interesting .. Overall, nice contest.. Thanks :)

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

I was not able to submit working B. Is there a "funny" trick or something?

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

It was amazing, thanks!!

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

What a great contest with fun problems!!!

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

Sorry my bad :((

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

Nice Contest Able to solve Only 2 .. but real Div2 is Back How to solve D ?

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

    Build the graph from array 'b', since it's acyclic topo sort exists, process the numbers in that order...watch out when the value is negative, in that case process it's child first....

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

Man I was first officially right after solving A and B but then got bogged down by debugging on C and didn't get much time to implement D so pretty much no delta change.

Speedforces

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

Question B ** Why output for 4 is 9998? shouldn't it be 9990? There I can't see any restriction for using 0 in the end.

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

For problem c, we had to topologically sort elements of a using b, and then do a forward pass picking only non-negative elements and another backward pass picking the remaining elements right?

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

My solution for problem D outputs "1 3 4 2 5 6 8 9 10 7" as an order of operation for 3rd sample test case. I checked this order by simulating it on computer and it is giving answer -9 which is correct. Can someone help me to find out what is wrong?

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

Problem C: Can anyone explain why is the answer for test case 2 in example 2 of Problem C is "NO".

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

In C, I checked at each node if the happiness count at each node is not smaller than its subtree, I calculated the count of happiness at i th node by fetching total people living at that node and its subtree. Now I have happy-sad at that node (given) and happy+sad = total, I checked if the number of happy people in its subtree is not greater than this value, apart from adding other small conditions. Is it the right approach? Although I could not implement it :(

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

I think writing $$$2000$$$ is better than $$$2\cdot 10^3$$$ in case of small constraints. I spent an hour trying to solve E for $$$2\cdot 10^5$$$ before I noticed the constraint. Of course, it was my fault (I even read maximum in place of minimum) but it still is more convenient.

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

https://mirror.codeforces.com/contest/1388/submission/88470430

For problem B. Can anyone explain why this gives TLE? This is in PyPy, but same submission in Python gives AC.

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

    Maybe python interpreter not doing loop, but just s+="8"*smth

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

    When you add a character python creates a whole new string, so your complexity is n^2.
    Get used to making lists of characters and then ''.join(L) at the end.

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

      If i understand correctly then s=s+'8' is O(n) and s+='8' is O(1) and i have used s+='8' in my code. Even the same code run in python gives AC so definitely it does not create a new string in Python. Maybe in PyPy it does.

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

        Could be, but that why I:
        1) Only use pypy if there is lots of calcualtions involved (for strings,graphs — always python)
        2) Use str.join so I won't fail even if I choose pypy by mistake (and it happened many times before).
        3) Use str.join because I am human and I can always do s = s + c by mistake...

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

        Well. Optimized appending to the string is pretty much CPython implementation detail and is not guaranteed by the python language per se.

        So you're right. In CPython this operation is heavily optimized and I believe is O(1), i.e. it does not allocate a new string every time (there are exceptions actually to maintain external immutability and this immutability is exactly the reason why most people believe that it should always be O(n)) and in PyPy is O(n).

        Actualy, I knew that this is not guaranteed in python, but never thought it would become a problem in cp when switching to pypy.

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

Appreciate the very strong pretests in the contest. Also interesting problems, C was a graph problem after many contests and it was pretty nice imo.

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

Problem C is quite annoying. I look through some PP code after contest and get nothing about why I'm wrong or even whether I failed to judge something.

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

A very good Problemset after decades.

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

MikeMirzayanov

Cheating caught in today's contest https://mirror.codeforces.com/contest/1388/submission/88511065 https://mirror.codeforces.com/contest/1388/submission/88510232

They have same codes only function names and variables are cleverly changed.

And the second guy deliberately submitted late when he was sure he will get 3 AC's.

Dont know why people show such teamwork in CF just to increase their ratings.

Their other submissions from the contest are also same.

Shame.

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

In second question, if n=4 then the answer should be 9990, right?. Similarly if n=5, it should be 99980?

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

88492256 Why my submission of question B got TLE in system testing.... help

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

    Same thing happened to me.

    s += '9' will work in time. s = s+'9' will not...

    I think the += operator knows to add on to an existing string (like push_back on a vector) while the + operation treats it as creating a new string.

    Very annoying (and to me, something I thought would have been caught in a pretest at least).

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

    While adding new charachters to the string you wrote: s = s + '8' which has complexity O(n) and as you do this operation n times the overall complexity of your code becomes O(n^2)

    You should have written s+='8' for appending charachters as it has compexity O(1)

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

It's interesting that if I don't hack Geothermal's problem E code, my first submission of problem E will pass all tests.

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

Can someone please help me out with C. Here is my approach :
1. Do DFS and store the total population of current city and the cities below it.
2. Then do DFS and find the number of people having mood in the children cities.
3. Find if the current population of city is good enough to satisfy all conditions .

Link to code : https://mirror.codeforces.com/contest/1388/submission/88521378
Thanks in advance !

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

I think I still have to practice a lot.

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

Problems of this round were truly amazing. Loved it <3.

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

The contest was great! And many many thanks for the good samples.

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

In the contest i wrote a solution for problem C which exceeded time limit on test 11: According to me it is an O(N) solution. Can somebody figure out the issue.

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

So, for problem E, if I assume at least two projections touch each other in the optimal answer, I have 2*n possible vectors to choose. And if I check all these cases, the answer should be the minimum of all the answers, right? Is this approach correct ? If so, why is the number of submissions so less ( because of geometry? )?

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

    Don't you have n^2 possible vectors to check? And then you have to check in O(1) instead of O(n)

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

      There won't be n2 possible vectors because we only need to consider the adjacent pairs when sorted by the start point or end points. If we choose two random pairs, the segments whose starting point lie between these pairs cannot be projected without them intersecting.

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

    If we consider the effect of the projection $$$(a, b)$$$ on an interval $$$(l, r)$$$ at height $$$y$$$, then our new interval is projected onto $$$(l - y\cdot\frac ab, r - y\cdot\frac ab)$$$. If we let $$$t = -\frac ab$$$, then this is simply $$$(l+yt, r+yt)$$$. Thus, view the intervals as buses with speed $$$y$$$ and location at time $$$0$$$ equal to $$$(l, r)$$$. We want to find a time $$$t$$$ where no two buses overlap, and we minimize the length of any interval containing all the buses.

    If we go to time $$$t = -\infty$$$, the fastest bus should be all the way on the left, while the slowest bus is all the way on the right. At time $$$t = +\infty$$$, the fastest bus in on the right, and the slowest bus is on the left. It's also clear that the time with the minimal interval is when two bus endpoints are touching. To reverse the order, there are $$$\mathcal O(N^2)$$$ crossings. We can process them by time, and keep track of how many buses are crossing at each point in time. Whenever there are $$$0$$$ crossings, then we simply want to find the maximal value of the endpoint of a bus minus the minimal value of the endpoint of a bus. This can be done with Convex Hull Trick. Overall, this will take $$$\mathcal O(N^2 \log N)$$$ where this comes both from sorting the $$$\mathcal O(N^2)$$$ events and the Convex Hull Trick.

    88530891

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

C: Could anyone please tell why is it giving TLE?

https://mirror.codeforces.com/contest/1388/submission/88528267

typedef long long ll;

ll fillp(vector<vector<ll>> &g, vector<ll> &p, ll cc, vector<ll> &nop, vector<int> &vis)
{
	ll tnop = 0;
	vis[cc] = 1;
	for(int i = 0; i < g[cc].size(); i++)
	{
		ll nc = g[cc][i];
		if(!vis[nc])
			tnop = tnop + fillp(g, p, nc, nop, vis);
	}

	nop[cc] = p[cc] + tnop;

	return nop[cc];
}

bool flag = true;
ll check(vector<vector<ll>> &g, vector<ll> &sad2, ll cc, vector<int> &vis, vector<ll> &p)
{
	int nos = 0;
	bool ok = true;
	vis[cc] = 1;
	for(int i = 0; i < g[cc].size(); i++)
	{
		ll nc = g[cc][i];
		if(!vis[nc])
		{
			nos = nos + check(g, sad2, nc, vis, p);
			if(flag == false)
				return INT_MIN;

			ok = false;
		}
	}

	if(!ok && min(2 * p[cc], sad2[cc]) + nos < sad2[cc])
	{
		flag = false;
		return INT_MAX;
	}
	
	return sad2[cc];
}

int main()
{
	int t;
	scanf("%d", &t);
	while(t--)
	{
		ll n, m;
		scanf("%ld %ld", &n, &m);

		vector<ll> p(n + 1);
		for(int i = 1; i < n + 1; i++)
			scanf("%ld", &p[i]);

		vector<ll> h(n + 1);
		for(int i = 1; i < n + 1; i++)
			scanf("%ld", &h[i]);

		vector<vector<ll>> g(n + 1);
		for(int i = 0; i < n - 1; i++)
		{
			ll x, y;
			scanf("%ld %ld", &x, &y);

			g[x].push_back(y);
			g[y].push_back(x);
		}

		vector<ll> nop(n + 1);
		vector<ll> sad2(n + 1);

		vector<int> vis(n + 1);
		fillp(g, p, 1, nop, vis);

		bool ok = true;
		for(int i = 1; i < n + 1 && ok; i++)
		{
			sad2[i] = nop[i] - h[i];
			if(nop[i] < abs(h[i]) || sad2[i] % 2)
			{
				ok = false;
			}
		}

		if(!ok)
		{
			printf("NO\n");
			continue;
		}


		flag = true;
		vector<int> vis2(n + 1);
		check(g, sad2, 1, vis2, p);

		if(flag)
			printf("YES\n");
		else
			printf("NO\n");
	}
}
»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

My approach for C was:

Stored the dfs from 1 in an array. Then Reversed it.

Now we iterate the array. (starting from the leaf nodes.)

For each node we maintain good and bad people passed through it. Then we traverse this reversed dfs, and for each node all it's children's good and bad can be good for our current node. Also the people who live in the present city can be good as well , thereby we try to maximize the good cases. Then we fix current node's good and bad such that we maximize good and have just enough bad to make happiness[i].

For any node if we don't have enough good or bad , it's simply a NO.

Please help in my Code. A failing test case please.

Edit: Sorry I thought its bad instead of sad.

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

    Hey, I feel that you didn't accommodate the fact that bad (sad) people can actually be residents of the given node and children nodes may have less sad nodes than parent because their home was inside parent.

    I created a class with intuitive variable names if you want to check my code out! 88503365

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

what a great contest ! Thank You all .. Denisov make more contest with your team <3

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

A very good match, but the difficulty gradient is not good. Question b can be a little harder, and question c should be easier. I passed c after the match. If I have two and a half hours in the match, I can solve c. To summarize my code, I feel that my code is too long and not concise. And typing speed is too slow. Many areas need to be improved.

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

I appreciated the convexity in Problem E. I could best picture the projections as the shadows from an infinitely distant light source.

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

Respected Sir,

I would request for a recheck on my solution submitted to Problem B from Codeforces Round #660. I have been shown Time_Limit_Exceeded on my solution, but that same solution when I executed it through the custom invocation in codeforces on the same test case it was executed in 658 milliseconds. I would create a great impact on my ratings. I would request you to give a recheck if possible.

I have attached my solution to the problem.

88478273 Codeforces Round 660 (Div. 2) standings

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

Thank you for very nice problems! They was a good balance of diffculty (at least A, B, C that I tried).

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

When will the ratings update?

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

https://mirror.codeforces.com/contest/1388/submission/88494957 (Contest Submission) https://mirror.codeforces.com/contest/1388/submission/88531246 (Unofficial Submission)

EXACTLY IDENTICAL FILES First file gave TLE in System Testing, second file got Accepted. May I know why?

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

this is my first contest. i solved the first 2 problems but i am still unrated... waws this contest unrated??

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

Why in the problem B this solution gave TLE in the contest [submission:https://mirror.codeforces.com/contest/1388/submission/88476304] while in practice the same solution passed [submission:https://mirror.codeforces.com/contest/1388/submission/88533918]? Please can you clarify this doubt Denisov MikeMirzayanov

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

Bad comprehending killed me..

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

Rating predictor seems to be a little off on accuracy today

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

My video solutions to problems A, B, C, D.

Enjoy watching.

https://youtu.be/0ExktAwScLc

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

I used to do cf regularly couple of years back but has started attending recently again. Honestly the new rounds came to me a bit unfamiliar until this round. Gave me a taste of past classic rounds.

Hoping to see round like this one more. Kudos !!!

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

Can someone plz tell me why we cannot add 0 rather than 8 in some of the positions in B??

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

Rating changes for this round is looking a bit weird according to the predictor.Are these changes final or will they be checked again?

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

In Problem A: It is said to print "4 different positive integers", but why one of those 4 positive integers can not be zero ('0')? Where is the range is mentioned? Please help me to understand the constraint. Thank you.

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

    Normally "0" is not considered when they say "Positive Integers" meaning it is the set [1,infinity). If they say "0" can also be included in the answer, then they will Explicitly mention "Non-Negative Integers" (instead of Positive integers) which is the set [0,infinity).

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

Is that possible that vector does not response to push_back() in any case?

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

.

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

Dear Codeforces Community, I received a mail from you and there were issues regarding same solutions using different accounts. Both the accounts belong to me and I have the second one as a backup account. The code is written solely by me only. I have proofs that both accounts belong to me and I am the only one writing the code. I had a rating bump yesterday but its been cancelled now. I didn't know CF community has harsh rules against 2 accounts. This was my first time so if you could look into the problem. MikeMirzayanov System Please help me.

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

Congratulations to adedalic for amazing coordination of this round!

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

In this round, something strange happened, I had a pretest passed the verdict , but I got RTE on Test 1 during the system test due to me calling a[-1] in one part of the code. Now I understand that the mistake is mine but how does the same compiler give different answers for the same input. Here is the link to my submission. Since I was effected negatively due to the compiler issue, is it possible to be exempted from rating change in this round?

Link to the submission : https://mirror.codeforces.com/contest/1388/submission/88495272

MikeMirzayanov adedalic

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

Nice name Mai_madarchod_hu gave me a good laugh, also congrats on winning

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

MikeMirzayanov I have received a message about a solution which "significantly coincides" with another solution. https://mirror.codeforces.com/contest/1388/submission/88479017 https://mirror.codeforces.com/contest/1388/submission/88498361

I think that it is just same template + similar solution (which is likely to happen for easy problems)

Please make sure that I don't receive any "penalties" from this.

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

when will be the next div. 3