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

Автор SlavicG, 2 года назад, По-английски

Happy Holidays Codeforces! 🎅

mesanu, flamestorm and I are very excited to invite you to Codeforces Round 918 (Div. 4)! It starts on Dec/28/2023 17:35 (Moscow time).

The format of the event will be identical to Div. 3 rounds:

  • 5-8 tasks;
  • ICPC rules with a penalty of 10 minutes for an incorrect submission;
  • 12-hour phase of open hacks after the end of the round (hacks do not give additional points)
  • after the end of the open hacking phase, all solutions will be tested on the updated set of tests, and the ratings recalculated
  • by default, only "trusted" participants are shown in the results table (but the rating will be recalculated for all with initial ratings less than 1400 or you are an unrated participant/newcomer).

We urge participants whose rating is 1400+ not to register new accounts for the purpose of narcissism but to take part unofficially. Please do not spoil the contest for the official participants.

Only trusted participants of the fourth division will be included in the official standings table. This is a forced measure for combating unsporting behavior. To qualify as a trusted participant of the fourth division, you must:

  • take part in at least five rated rounds (and solve at least one problem in each of them),
  • do not have a point of 1400 or higher in the rating.

Regardless of whether you are a trusted participant of the fourth division or not, if your rating is less than 1400 (or you are a newcomer/unrated), then the round will be rated for you.

Special thanks to the VIP testers: AlperenT, KrowSavcik!

Thanks a lot to the testers: Qualified, Kaushal_26, htetgm, MADE_IN_HEAVEN, sandry24, Starlight-Sailor, Vladosiya, LucaLucaM, Gheal, tvladm, Dominater069, haochenkang, xiaowuc1, pashka, vrintle, BucketPotato!

And many thanks to Vladosiya for translating the statements!

We suggest reading all of the problems and hope you will find them interesting!

🎄 🎄 🎄 Good luck to everyone and enjoy the holidays!!! 🎄 🎄 🎄

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

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

Thank you

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

very handsome.

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

I promise to solve at least 4 problems.

P.S. Cool photo!

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

This is my first out of competition and first unrated round

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

Thank you! Nice photo.

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

Every div 4 is good

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

Finally, this is my first unrated contest... I hope I will be able to solve all problems under contest time .... Merry Christmas and happy new year to all ....

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

I think conducting the div4 contest is the best holidays gift for the people having rating less than 1400.

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

Hope to be a great contest before Christmas...

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

Div4 should be arranged more frequently. Hoping for a great contest!

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

Are there watermarks on those Christmas hats?

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

so handsome

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

It will be my first Div 4 participation ^_^

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

I would aim to solve >80% problems.

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

The cap on your head looks edited

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

As a tester, Santa helped me test the contest

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

Wow! Dominater069 was a tester. That's great!

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

flamestorm face reveal!?!?!!

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

As an unemployed tester, I wish all participants happiness and employment.

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

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

As VIP testers, this was our testing room:

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

i wanna be specialist on this contest :)

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

Best of luck to all participants!

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

As a tester, I changed my color.

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

Eh, 2022-2023 is over, it was not like 2020, which is good, but I remember it as one of the most important years, I hope that next year will be successful for you all

zac-durant-6-Hz-PU9-Hyfg-unsplash-1080x675

I hope that for many every new year will only be better

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

My first Div.4 participation too! As a noob, hope the questions are friendly to me so that I can solve questions that less than 1300 smoothly. good time!

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

Hoping I could reach specialist :D

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

Thank you!

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

Can't wait to get +ve delta

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

Merry Christmas!

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

I hope the problems are as easy as it is to spot the fake caps in the picture ;)

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

Thanks for the round!!

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

Good luck everyone

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

in queue LOL

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

in the statement of Problem D:

mistake: 1<=n<=2*10^5 correction: 2<=n<=2*10^5

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

So many people have registered for this round that I had to wait 20 minutes to see the verdict for problem A.

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

Thanks for the round !!!

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

Loved the problems on this round <3

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

Awesome problems, guys! Keep it up!

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

Nice contest

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

Is the person replying to the questions during the contest a bot or online human???

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

Fun fact: $$$G$$$ can be solved using GPT $$$4$$$ without any hints.

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

it's over,

I will never reach cyan 🤡

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

Is MO decomposition in F an overkill? :D

My solution: 239387414

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

    might be, solved it using ordered sets, although i believe the author had a simpler solution for F of a Div 4!, btw what was your reasoning behind G?

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

      Basically we clone each vertex $$$n$$$ times. Each clone will be a pair, where first element is number of vertex and second is bicycle we use after we visit this vertex. So, now we just use dijkstra algorithm to find min path to ($$$n$$$, $$$any$$$-$$$bicycle$$$). You just need to find some transitions when you start using different bicycle. Something like this.

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

    You can compress the coordinates, sort the intervals and then use fenwick or segment tree to calculate the answer.

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

what is the idea of E? i felt its harder than F and evne G ( if i got the idea of G correct)

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

    think about the prefix sums of the odd-index and even-index arrays. What can you say about the prefix sum values at the left and right endpoints of a good subarray?

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

    Let $$$\mathrm{sum_{even}}$$$ denote the sum of values on even indices on our current subarray, and define $$$\mathrm{sum_{odd}}$$$ similarly.

    $$$\mathrm{sum_{even}} = \mathrm{sum_{odd}}$$$

    $$$\mathrm{sum_{even}} - \mathrm{sum_{odd}} = 0$$$

    Now, multiply all values on odd indices by $$$-1$$$ in the original array. The condition now becomes

    $$$\mathrm{sum_{even}} - (-1) \cdot \mathrm{sum_{odd}} = 0$$$

    $$$\mathrm{sum_{even}} + \mathrm{sum_{odd}} = 0$$$

    The left side is just the sum of the current subarray. Thus, we need to find a subarray with sum $$$0$$$ $$$\Leftrightarrow$$$ you need to find two equal prefix sums.

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

      Still clueless could you explain it to me?

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

        What part of my comment did you not understand?

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

          As to why we need that particular subarray where all the odd incidces sum up to zero and why do we need to use prefix sum here.

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

            why we need that particular subarray where all the odd incidces sum up to zero

            That's not what I said; odd indices shouldn't sum up to zero. Let me try to explain everything again with more details.

            Let $$$\mathrm{sum_{even}}$$$ denote the sum of values on even indices on our current subarray, and define $$$\mathrm{sum_{odd}}$$$ similarly.

            According to the problem statement, we need to find a subarray such that $$$\mathrm{sum_{even}} = \mathrm{sum_{odd}}$$$

            Subtract $$$\mathrm{sum_{odd}}$$$ from both sides:

            $$$\mathrm{sum_{even}} - \mathrm{sum_{odd}} = \mathrm{sum_{odd}} - \mathrm{sum_{odd}}$$$

            $$$\mathrm{sum_{even}} - \mathrm{sum_{odd}} = 0$$$

            Now, let's multiply all values on odd indices by $$$-1$$$ in the original array. Thus, $$$\mathrm{sum_{odd}}$$$ becomes $$$-\mathrm{sum_{odd}}$$$ in our new array.

            This means that the required condition is now

            $$$\mathrm{sum_{even}} - (-\mathrm{sum_{odd}}) = 0$$$

            $$$\mathrm{sum_{even}} + \mathrm{sum_{odd}} = 0$$$

            For any subarray, $$$\mathrm{sum_{even}} + \mathrm{sum_{odd}}$$$ is just the sum of that subarray. This is because every element in the subarray is either counted in $$$\mathrm{sum_{even}}$$$ or in $$$\mathrm{sum_{odd}}$$$.

            Now, we just need to find a subarray with sum $$$0$$$.

            Let $$$p_i = a_1 + a_2 + \dots + a_i$$$, i.e. the array $$$p = [p_1, p_2,\dots, p_n]$$$ is the prefix sum array of $$$a_1, a_2,\dots, a_n$$$. Remember that this array $$$a$$$ is the one from input, with all values on odd indices multiplied by $$$-1$$$.

            Recall that $$$a_l + a_{l+1} + \dots + a_{r} = p_r - p_{l-1}$$$, i.e. the sum of a subarray of $$$a$$$ can be expressed as a difference of two prefix sums.

            Since we need a subarray with sum $$$0$$$, we need two prefix sums $$$p_r$$$ and $$$p_{l-1}$$$ such that $$$p_r - p_{l-1} = 0$$$

            Add $$$p_{l-1}$$$ on both sides:

            $$$p_r - p_{l-1} + p_{l-1} = p_{l-1}$$$

            $$$p_r = p_{l-1}$$$

            This means that we just need to find two equal values in the prefix sum array. Remember to also include $$$p_0 = 0$$$ in your prefix sum array, since this might be needed when $$$l = 1\ \Leftrightarrow\ l-1 = 0$$$.

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

    a -> pref sum of odd indidces b -> pref sum of even indices for range l...r to be valid ar — al = br — bl -> (ar — br = bl — al) now you know how do it. it's similar to 2 sum problem

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

can someone tell me if my approach for G is correct or not for every node i (min time to reach from 1 to i) + (min time to reach i to n) ans is min of all those nodes;

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

    Trying same thing from hours but don't know why it's not working... I hope some explain flaw in this approach

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

      I think the above approach assumes that the optimal route would involve a direct path from 1 to i and then i to n, and this surely is the case in the first sample test case. However, it may not always be the case as the minimum time route is a walk(not a path always) for the problem.

      Consider the modified weights and bike slowness:

      5 5
      1 2 2
      3 2 1
      2 4 5
      2 5 20
      4 5 100
      10 5 3 1 2
      

      In this case you may observe that the optimum route goes as 1-2-3-2-4-2-5. So, the solution in this case is time(1,3) + time(3,4) + time(4,5). This can be generalized and you can make test cases where the optimum route is a combination of many simple paths, and so the assumption that time(1,n) = min over i{time(1,i) + time(i,n)} fails.

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

can somebody say why 239395416 getting TLE on 21st testcase?

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

What is the time complexity of my code? Isn't it O(nlogn)? 239378769

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

can I do F in PYTHON without use SortedList?

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

Can anyone explain ideas behind F and G?

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

Nice contest, B was a bit diff, I hate working with 2D arrays

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

i have used this code to count the no. of inversions i changed it little bit. so i hope this is not considered as cheating and my submissions will not be skipped as many participant may used the same code

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

I have no idea why this code is printing an additional character, and it costed me a good contest. Can anyone help me figuring out this?

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

in problem F why the answer for this input is 9 ?

6
2 6
3 9
4 5
1 8
7 10
-2 100
  • »
    »
    2 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    point(4,5) meet with (3,9) at 2nd sec ->count=1; point(2,6) meet with (4,5) at 3rd sec ->count=2; point(1,8) meet with (4,5) and (2,6) at 3rd,5th sec ->count=4; point (-2,100) meet with every other point at 7th,8th,10th,11th,12thsec ->count=4+5=9;

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

Can any one tell why my submission to G is giving WA ? Also a clarification i need, if Salvic is at city C and has bought some k bikes till now, then he can use any bike(1 to k) to travel to neighbouring cities of j right ?

My latest submission

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

Can someone please explain the test case 1 of problem G? how is 19 achieved?

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

Hello Everyone What is this trusted participant thing? I see the standings have a trusted participant tag. I participated after long tume. Will this round be unrated for me?

  • »
    »
    2 года назад, скрыть # ^ |
     
    Проголосовать: нравится +10 Проголосовать: не нравится
    Regardless of whether you are a trusted participant of the fourth division or not, if your rating is less than 1400 (or you are a newcomer/unrated), then the round will be rated for you.
»
2 года назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Amazing contest!!! Solved all except E lol. Ordered Multiset FTW in F.
Thanks for the great round SlavicG mesanu flamestorm and all testers.

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

Hoping to become a pupil. Also can anyone explain the test case for F? -10 10 -5 5 -12 12 -13 13 How is it 6?

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

    Everyone greets each other. (-5,5) and (-10,10) meet at 5 (-5,5) and (-12,12) meet at 5 (-5,5) and (-13,13) meet at 5 (-10,10) and (-12,12) meet at 10 (-10,10) and (-13,13) meet at 10 (-12,12) and (-13,13) meet at 12

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

    t = 0. A is at -5, B is at -10, C is at -12, D is at -13.

    t = 10. A is at 5, B is at 0, C is at -2, D is at -3.

    t = 15. B is at 5 and greets A. C is at 3, D is at 2. 1 greeting.

    t = 17. C is at 5 and greets A. B is at 7, D is at 4. 2 greetings.

    t = 18. D is at 5 and greets A. B is at 8, C is at 6. 3 greetings.

    t = 20. B is at 10, C is at 8, D is at 7.

    t = 22. C is at 10 and greets B. D is at 9. 4 greetings.

    t = 23. D is at 10 and greets B. C is at 11. 5 greetings.

    t = 24. C is at 12, D is at 11.

    t = 25. D is at 12 and greets C. 6 greetings.

    t = 26. D is at 13.

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

my face when tourist got hacked ._.

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

Здравствуйте, я недавно закончил решать Codeforces Round 918 (Div. 4). Завершил три задания из 8 успешно. Как я могу узнать место и посмотреть результаты?? Заранее спасибо

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

What was the idea of F? Segment trees?

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

Not even a clue how to solve E by prefix sum and Why to find a zero prefix sum with the addition of sum being calculated with multiplying by -1 to odd indicies :(

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

    sum_odd(l, r) = sum_even(l, r)

    <=> sum_odd(l, r) — sum_even(l, r) = 0

    or

    <=> sum_even(l, r) — sum_odd(l, r) = 0

    we can either pick sum of odd elements or even elements, and negate it, now it turns into the classical problem of finding out whether a subarray of sum 0 exists

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

why this solution gets time limit on test 3: https://mirror.codeforces.com/contest/1915/submission/239385030

isn't time complexity of it O(n*log n)

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

Knew about them 30 minutes before the contest and now it's everywhere

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

F is the worst problem I have faced till now, why did these tests allow O(n^2) solutions to squeeze in? I did not expect O(n^2) solutions to pass at all.

»
2 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится
int n ; cin >> n ; 
    vector< pair<int,int> > v ;
    for(int i = 0 ; i < n ; i++){
        int a, b ; cin >> a >> b ;
        v.push_back({a,b}) ;
    }
    sort(v.begin(), v.end()) ;
    set<int> s ;
    int ans = 0 ;
    for(int i = 0 ; i < n ; i++){
        auto it = distance(s.upper_bound(v[i].second), s.end() );
        ans += it ;
        s.insert(v[i].second) ;
    }
    cout << ans << endl ;
»
2 года назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

lol. tourist's solution of G got hacked.

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

My screencast: https://youtu.be/1cdLQi_0_XQ?si=J7HiLQiXyFT0fe_u finished in 29 mins

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

I solved 4 problems and Iam a new comer and this contest is unrated for me. Can I know why?

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

    I am not trying to be rude but can you please read the announcement blog again?

    • 12-hour phase of open hacks after the end of the round (hacks do not give additional points)

    • after the end of the open hacking phase, all solutions will be tested on the updated set of tests, and the ratings recalculated

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

can someone try to hack my G solution? https://mirror.codeforces.com/contest/1915/submission/239320792
I feel like it should be able to get TLE. I followed an approach similar to bellman ford algorithm. I looped through j and used
dist[1 to i] = min(dist[1 to i], dist[i to j] + s[j]*greedy_dist[i to j])
to relax the nodes like in bellman ford

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

can we solve f without fenwick tree

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

Can anyone please tell what is wrong in this method for problem G ?

int main(){
    ll tt;cin>>tt;
    while(tt--){
        ll n,m;cin>>n>>m;
        vector<vpll> v(n+1);
        rep(i,m){
            ll x,y,z;cin>>x>>y>>z;
            v[x].pb({y,z});
            v[y].pb({x,z});
        }
        ll a[n+1];
        rep1(i,n)cin>>a[i];
        set<vll>q;
        q.in({0,a[1],1});
        ll inf = 1e14;
        vector<vll>dis(n+1,vll(1001,inf));
        rep1(i,1000)dis[1][i] = 0;
        while(q.size()){
            
            ll d = (*q.begin())[0];
            ll i = (*q.begin())[2];
            ll mn = (*q.begin())[1];
            q.erase(q.begin());
            if(dis[i][mn]<d)continue;
            for(auto it : v[i]){
                ll ch = it.fi;
                ll wt = it.sec;
                ll x = min(mn,a[ch]);
                if(dis[ch][mn]>d+mn*wt ){
                    dis[ch][mn] = d+mn*wt;
                    q.in({dis[ch][mn],x,ch});
                }
            }
        }
        ll ans = inf;
        rep1(i,1000)ans = min(ans,dis[n][i]);
        cout<<ans<<endl;

    }
}

dis[i][j] means minimum distance to reach ith node if the minimum slowness factor is j to reach node i.

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

    because you are initializing that time to reach node $$$1$$$ for every slowness is $$$0$$$, which is wrong, since you can reach back to node $$$1$$$ after taking the slowness of some other node and then procees with that for further $$$optimal$$$ answer but you block it since when it reaches node $$$1$$$ its sees the time to be minimum($$$0$$$) already.

    small test case

    Hope that helps !

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

everybody talking about tourist hacked problem, but

i got hacked on E for using unordered_map instead of map. it's the first and last time i got hacked for this.

Here a useful blog about that: https://mirror.codeforces.com/blog/entry/62393

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

Idk my solution to G was different from most so...

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

239194376 why is it TL? can some one pls look)

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

I was thinking about this problem F, It's something like count the number of inversions in an array

I solved using ordered_set, binary trie and merge sort(Submission), and I know how to solve using Fenwick tree/Seg Tree.

I wanted to know if there is something easier I can do

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

    If:

    • Walker 1 starts behind walker 2
    • Walker 1 ends in front of walker 2

    Walker 1 will greet walker 2.

    This is true because if walker 1 starts in front of walker 2, it will reach walker 2's end before walker 1, and if walker 1 ends behind walker 2, it will stop before it reaches where walker 2 stopped.

    So we can sort the starting points in ascending order, and then for each walker, we can count how many walkers greet them by counting how many of the walkers we've iterated through so far have an endpoint ahead of our current walker. The order statistic tree facilitates this very cleanly (and at 1/10th the speed). 239357334

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

Thx

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

why O(nlogn) solution not pass problem F?

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

Hack this, please!

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

F can use sweep line?

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

can someone tell on which test case my solution of e got hacked

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

In problem E, unordered_map gives TLE, but map gives accepted verdict. Could anyone please let me know why?

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

It's my first Div 4 participation

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

I'm actually a bit confused regarding this round, as my rating is below 1400 and yet after solving 2 questions, my rating hasn't been increased. If anyone could please help me explain the situation please.

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

Can anyone explain why me solution got AC? it has a time complexity of n^3 https://mirror.codeforces.com/contest/1915/submission/239328701

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

Where can I find the editorial? or is it unavailable

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

One person has been abusing me by sending messages because I hacked his/her solution in this contest. Is there a way to report that person?

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

For anyone who wants to know more about similar problems like G.

Here is a great blog on shortest path modelling:

https://mirror.codeforces.com/blog/entry/45897

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

Editorial when?

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

I solved 5 out of 7 problems and they were accepted. Now it shows only 2 out of 7 were submitted ? What the hell. I just checked 3 hours ago it showed 5 out of 7 were accepted

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

Is it possible for a solution to be rejected due to TLE during system testing even if the submission was earlier accepted during the contest ?

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

I would like to ask why this submission receives a WA in the new testcases (C) https://mirror.codeforces.com/contest/1915/submission/239236542

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

    You are typecasting to double, so it is possible that some value which is not perfect square can also match(due to precision issues). You had to typecast to long long. If it was a perfect square, then only it will match

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

Why was this unrated for me? I've never been >1400 so I'm really confused

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

What is the problem with the unordered_map? I used the same solution just a little change using map instead of unordered_map got AC on problem E.

Why is this happening?

TLE submission:

AC submission:

UPD: Found solution on this

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

In Question E

Why unordered_map has given TLE in test case 16

But ,using normal ,it gets accepted,Although we are using only find function of map

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

Could someone please help me find the editorial? Or perhaps lead me to the solutions of E, F and G questions? I tried to implement the solution of vgtcross given in the comments under but I am not sure where I have messed up. Here is the submission. 239587509

  • »
    »
    2 года назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    • The editorial is here. You can find it by going to the contest dashboard (problem list); on the bottom right, there is contest materials -> tutorial.
    • About your solution to E, it seems like you were able to get it working. About the use of unordered_map, you should probably read this (unless you did already).
»
2 года назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

I solved two questions in the contest and both were correct then why did i get an overall negative 28 and a penalty of 54

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

although i could not take part in it on time,but after i vp,i feel good?happy everyone

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

SlavicG why u retired