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

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

Привет, Codeforces!

В Jan/13/2019 17:35 (Moscow time) начнётся Codeforces Round 532 (Div. 2). Раунд будет рейтинговым для второго дивизиона (рейтинг ниже 2100). Как обычно, участники из первого дивизиона могут написать контест вне конкурса.

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

Задачи были подготовлены мной, den2204.

Спасибо MikeMirzayanov за платформу Codeforces, KAN за помощь с идеями для задач и координацию моей работы. Спасибо vintage_Vlad_Makeev, Andreikkaa, Flyrise, Um_nik, Aleks5d и ---------- за помощь в подготовке и тестирование раунда, arsor за перевод условий на английский язык, arsijo за помощь в проведении раунда. Отдельное спасибо Andreikkaa за идею по задаче E.

Удачи!

P.S. Это мой первый раунд на Codeforces, поэтому не судите строго :)

UPD: Добавлен разбор. Всем спасибо за участие и за отзывы о контесте. Приношу свои извинения за скачок по сложности между задачами и за слабые претесты по некоторым задачам, учту это при дальнейшем составлении контестов.

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

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

Auto comment: topic has been updated by den2204 (previous revision, new revision, compare).

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

Honestly, not bad for your first contest! I hope you had a great time creating the contest and all of us participants would like to thank you for spending your time on this! We all really appreciate it! Hope to see you again as a writer den2204!

And to all participants: Good luck and have fun at the contest tomorrow! <3

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

Thanks Andreiikka for the idea of the problem E.

Segment Tree in E???

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

Finally a contest without faked colors !

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

:D

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

den2204, congratulations for your first contest as a problem-setter...

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

This is going to be my first contest of the new year. I am so excited. xD

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

Congratulate with your first contest, I think it will be greate :) Good luck all :D

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

Please make strong test cases

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

Разбалловка будет?

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

When there is a new problem setter its usually 2 condition : 1) the tasks are creative and fun to solve 2) the tasks are time taking and not fun to solve I hope for (1) :)

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

i hope your first contest will be great ^^

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

Scoring distribution?

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

come on!!!

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

why geometry??

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

Интерактивка без предупреждений незаконно.

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

Illuminati wants to know your location.

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

There is a drastic difference between A-C and D-F, so the contest turned into speed coding.

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

I hope you not to repeat it

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

Worst Problem statement with worst Explanation. Wasted 10 min in just understanding the problem Statements

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

Why D, E, F so hard? Massive AC-gap between C & D :(

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

A, B, C = A and D, E, F != DIV 2.

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

In problem F, are we supposed to answer the queries for maximum subarray xor? Probably somehow offline?

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

How we were supposed to locally test D?

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

How to solve D?

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

How to solve F?

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

    Take yesterday's G -> TLE with seg tree -> use divide and conquer that you can use just prefix/suffix -> done

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

      Yeah I got TLE with segment tree, very nice solution, thanks!

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

      Is it possible to merge two independent vector sets in better than 20^2 time?

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

        I don't think so. My solution computes suffix/prefix when dividing [l, mid) [mid, r) (to add a number to a prefix/suffix is O(bits) time) and then solves the queries with l < mid and r >= mid in O(bits^2).

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

      Your Gauss struct is black box for me.
      If you can provide some intuition how those max and min are working?
      First time I have seen inserting an element in O(bits).
      My implementation in O(bits^2) was giving tle.

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

        You can add number by number. So instead of thinking of a N*BITS matrix when you have N numbers, think of a BITS*BITS matrix where you insert one value at a time. Also, don't use vectors in code like this that uses a ton of memory, it'll use a lot more memory and it'll have more cache misses. For max, you have the basis so just go from the number with highest bit to lowest bit and activate the bit whenever you can.

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

          Got it. Thank You.

          What I have understood is that each no in your table has a bit (the most significant bit) associated with it. Similar to the basis vector which has at least one dimension with them.

          And that no is responsible for activating(max)/ deactivating(min) that particular bit.

          P.S. After reading I got core idea of your implementation. But was bit confused with just go from the number with highest bit to lowest bit So, I added prt function in your implementation. And then I came up with the above explanation.
          Thank you. :)

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

          In your submission (linked below), the Gauss::add() function confuses me.

          I think that the invariant for the Gauss class is that if table[i] > 0 then the $i$th bit of that needs to be set. But if you don't make that check in your add(), this invariant could be violated.

          Your submission did get AC, so what am I missing here?

          48339644

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

    You can split your array in chunks of size 20 and use sparse table on array of size n/20. Query can now be answered online in 20*20 time by sparse table query + adding elements partially belonging to a chunk one by one.

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

Does E have the following solution?

Sort all the edges according to c. Binary search over this to find the edge so that no cycle is present. Compute the topological order of this graph without cycle and add reverse remaining edges which violate the order.

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

    Sorry if I understand your idea wrong, but don't you mean to reverse all the edges that have a lower cost than the middle in your binary search ? I thought the same but there might be some edges that you can reverse that should not be reversed which made it so much harder

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

      You cannot reverse all the edges which have lower weight because you might end up getting cycles in new graph. Instead what you do is reverse those edges which violate the topological order as a directed graph has no cycles iff it has a topological order.

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

The problems were actually pretty good, but the difficulty gap was pretty bad. Hope you can balance the problems in the future!

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

Is there any nlog solution for F or it's just optimized nlog2?

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

How we were supposed to locally test D?

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

How to solve E? I thought of using finding a maximum spanning tree and every not used edge would be a flipped edge, but I didn't know how to implement a dsu for directed graphs.

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

Wasted the whole time on C. Dunno why got WA on D. Coded E just after the contest ended. Gonna kill myself if it passes.

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

Honestly speaking, the gap between C and D is very large. C is the normal Div.2 B and B is the normal Div.2 A.

Surely you didn't send problems to the problem pool like what Arkady did on the problem B. I mean it was like, n=6, m = 6 and 112556 then the answer is 000001

Need solution on D too. It really looks like pigeonhole, but I don't know how to do it.

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

What were the hacks for B and A? I managed to hack someone on B because his implementation had a time complexity of O((m — n) * n). Are there any other hacks for B?

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

How to solve C guys? I could not come with a solution during the contest :(

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

    Solve your homework on triangular formulas. If you did not take them yet, well you are rekt.

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

    The centers of the n outer circles make a regular polygon with n sides. Now focus on the centers of 2 adjacent outer circles and the middle circle. You have a triangle with side lengths (r+R), (r+R) and (R+R). You can also find all the angles in the triangle. Finally, you can use cosine theorem to get a formula: (2*R)^2 = 2*(R+r)^2 — 2*(R+r)^2*cos(A) [A is the center angle, actually A = 360/n]. Then, you can simplify and use the quadratic formula, or use binary search.

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

    What I did was visualized that the centers of the outer circles when connected formed a regular polygon with n sides. That polygon has its center coinciding with the center of the inner circle. We can calculate the length from the vertex of the polygon to the center of the inner circle using trigonometry and hence there is only one variable i.e R (here side of the polygon will be 2R). I am almost sure of my solution, I didn't take time to prove what I conjectured, so will come to know exactly if my hypothesis is right when final results are out.

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

    This is my idea,may be inefficient.

    draw some cases,we can find:

    The center of inner circle can make a Isosceles triangle with two conterminous outer circles' center,and two angles will be ,difine this as θ

    then we have (R + r)2 = R2 + (R·tan(θ))2

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

    If you connect the centers of two adjacent little circles and the center of the big one, you'll get a triangle. The sides of this triangle have lengths r+R,r+R and 2r

    . A little trigonometry will get you that the top angle is

    θ=2arcsin(r/r+R).

    Since you want the small circles to form a closed ring around the big circle, this angle should enter an integer amount of times in 360° (or 2π

    if you work in radians). Thus,

    θ=360°/n.

    From this, you can compute that

    r=Rsin(180°/n)/1−sin(180°/n).

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

    All you gotta realize is that centers of outside circles must be 2R away from each other. How to get centers? Well just do x = (r+R)cos(t) and y = (r+R)sin(t), where t = (2pi/n)*i. If you want to visualize draw two circles tangent to each other with radius r and R. They will be r+R away from each other, and assuming one of them is at 0,0 the other's coordinates can be gotten from sin and cos.

    Binary search: if distance < 2R the circles are too big otherwise they are too small.

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

Please tell me how to debug intractive problem or what is pretets 2 for D. Idea for D: Place king in 500,500. Divide chessboard in 4 pieces. Each piece has one corner as king position and one corner as chessboard corner. Find which of this 4 pieces has smallest number of rooks. Go to opposite corner with king moving only diagonally. Convince yourself it always works.

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

I'm surely misinterpreting the problem/making some really silly mistake, but I think the king can't guarantee having a check ?

Define Si to be the configuration where the black rooks are at the cells {(1, 1), (1, 2), ..., (1, i - 1), (1, i + 334), (1, i + 335), ..., (1, 999)}. Initially start with S1 and the white king at (1, 1). Now at some step, if the king's x coordinate changes from x to y (with |x - y| ≤ 1) then it's easy to see we can move some rook so that the rooks configuration become , so the king can never guarantee a check ?

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

Just curious to know, why does this submission on problem B doesn't get runttime error when he declares array of size exactly 100000.
My hack test

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

    Why would it get runtime error? n, m <= 100000 so it seems fine.

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

      array size has been declared as 100000. hence, array element range is between 0-99999. but he does arr[aa]++;
      hence it should get runtime when aa = 100000. Sorry, correct me if I am wrong.

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

        Ah, so he is accessing an element outside of the array. If he'd used std::vector instead of a plain array he would have gotten a Runtime Error. However, since he's using a plain array, his solution is doing undefined behaviour, which is bad, but most often it won't be a problem because he's accessing memory right next to the array.

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

        When you declare an array.Usually you will get an array a little bigger than you declare.That works in most computers.Include my computer,Codeforces computer and our school computer.And even a[-1] won't get Runtime Error in some computers.

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

OMG! I had a clean solution for D, but didn't consider the case of eating a rook. Didn't look at the CF error message :(( It was saying king ate rook

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

Trash contest...
1500 point problem solved by 3.5k and D problem solved by only 125 people. Also E problem is just classic know problem added binary search(here is the solution). I think F also range version of the XOR max problem(here is solution).
If you want to do such contest, better to not do. Educational Rounds much better than this kind of contests...

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

    Problem D was not actually that difficult. The entire contest was consistently simple IMO, which is fair.

    I do agree that this contest is more like an Educational round, tho. Because it's very easy to google solutions to some problems.

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

I do not want to judge you strictly. But What the hell.

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

I understand that it is not easy to make a well balanced contest, but the big jumps in difficulty of problems are really obvious in most of recent codeforces contests.

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

how to solve B?? Can anyone please explain??

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

Is it possible to hack someone's solution after the contest? Or how can I practice hacking (besides educational rounds)?

recurze, your B solution will probably run out of time on a test like:

100000 100000
1 2 3 4 ... 99999 1

I tried to hack it during the last 2 minutes of the contest but forgot to put an endl after the 1st line, so it wasn't accepted.

My the very first hack :D

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

Codeforces turning into Codechef :P

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

How to solve E?

Here's my idea: Run a DFS from any node, let onstack[i] denote if the ith node is currently being processed, also intime[i] denote the scan time of ith node(similar to topological sort algo). Now maintain a segtree for onstack nodes only, and use RMQ query where index is the intime of nodes. Whenever we find a backedge we calculate the minimum weight edge in the cycle using the segtree. Is this idea correct? Is there an easier way?

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

    I'm not sure if this is easier, but this was my solution.

    Task E Statement:

    Given a weighted directed graph, convert it into a DAG by reversing edges. You have to minimize the maximum weight of the edges that you reverse.

    If the given graph G = (V, E) is already a DAG, then the answer is 0.

    Let us choose a value k arbitarily. Let us call an edge heavy if it's weight is greater than k, else it is light.

    If Gheavy = (V, Eheavy) forms a DAG, then we can find a topological sorting of V in Gheavy. We can then arrange edges in Elight to be consistent with the topological sort.

    We can find the minimum value of k so that Gheavy doesn't have cycles using binary search.

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

      Are you reversing the direction of all the light edges? If so, then there might be a case where the original direction of a light edge might be a part of one cycle and after reversing it, it becomes part of other cycle.

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

        No, not all the light edges. We find a topological sort of Gheavy. Then we can ensure that all the light edges are oriented so that they are consistent with that order.

        We will only reverse those edges that are inconsistent with the order.

        This is my submission, but I'm not sure how readable it is. I don't use the terms heavy and light in the code. It also hasn't passed system tests yet.

        48354300

        EDIT: Passed system tests.

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

          what if the selected edges created 2 graphs, now we have 2 topological sorts what if we need to connect node from the first graph to another node from the second graph. example

          graph 1 with the visiting order
          A->B->C->D
          4  3  2  1
          graph 2 with the visiting order
          E->F->G->H
          8  7  6  5
          

          now we need to connect nodes (D, E) but order[D]<order[E] so we reverse it and we add it to the answer, but if we didn't reverse it the graph is still DAG. how we handle this case, it seems I'm missing something.

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

            what if the selected edges created 2 graphs

            You mean a disjoint DAG? That's a DAG as well, and it has a topological sort as well.

            In your example, there are many valid topological orders. Let us choose any one, say "EFGHABCD".

            If we have edge between D to E, then we must have the direction as E--->D (because that is what the topological order tell us).

            If the given edge is D--->E, then we will reverse it, else we won't.

            Hope it is clear now.

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

              Thanks for your respond, yea I understand that. but my question is, In the example, we can generate 2 topological sort

              ABCD->EFGH and EFGH->ABCD
              

              let's say we have edge E->D if we selected the first topological sort then we need to reverse the edge if we selected the second topological sort then we don't need to reverse the edge. so I see that selecting the topological sort actually affect the results, but it's not clear for me why selecting arbitrary topological sort is ok, did you got what I mean?! :D

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

                I think I understand your question.

                The observation is correct that choosing a specific topological sort affects the final resulting Graph (after reversing edges).

                The claim is that we could use any of it. But once we choose a topological sort, we can't change that.

                I think the best way for you to get this intuition but by generating examples.

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

      Sorry if this is obvious but how is minimizing the maximum weight of reversed edges the same as minimizing the sum of the weights of the edges we reverse.

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

Trash. Again.

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

Pretests of E are weak. I did not get TLE for the following DFS routine:

void dfs(int u) {
  visited[u] = 1;
  for (int v : g[u]) {
    if (visited[v] == 1) { // cycle and hence do not continue }
    dfs(v); // missing visited[v] == 2 check
  }
  visited[u] = 2;
}
»
7 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

Good round! Thanks for problem D!

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

2o50s2

contestant.

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

If I submitted two solution for same problem and both are right then which will be judged first or second one?

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

Yeah yeah contest was slightly unbalanced but I still think it was a good contest, especially if it's his first one. Tbh we've seen much worse here and I actually hope that den2204 will be the problemsetter for some later contests too. I mean, problemsetters also have to learn how to do it properly and I believe this contest was actually pretty good for his first one. Gratz man !

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

I'm so regretful to spend 14 minutes to think for a solution in C.

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

Solution for D (if anyone is interested)

Move the king to cell (500, 500) in less than 1000 moves. Now board is divided into 4 squares by king's column and row. At least one of these squares contains no more than 166 cells. Then move king to the corner opposite to that square by diagonal. We will get to the corner in 499 moves, but the other player will have to move all >=(666-166)=500 rooks to avoid checks. So he will not have enough moves to avoid checks.

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

Is there no hacking for this contest? I want to hack!!

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

How much time after the contest can we submit solutions again?

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

Anybody came up with a good solution for E ?

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

Honestly, task C is nothing to do with coding competition. Very hard to understand problem statements.

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

It was impossible to hack! pretests are stronger than they suppose to be!

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

system testing started yes!!!

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

Problem D can be solved without being able to move the king diagonally.

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

    Works up until test #6 :)

    Sorry this is not quite right. You have to move diagonally to the corner from the center. If you can't move diagonally, then you take one step either vertically or horizontally and terminate.

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

I got TLE on problem B :https://mirror.codeforces.com/contest/1100/submission/48351000

How do I speed this up?

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

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

D is a very nice problem. Thanks.

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

Pretest for E wast too weak

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

The worst contest in my life

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

For problem D got WA on test 40. Is there any way to know what that test was? Here is my submission.

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

Even the system tests are weak for E. (Attaching previous comment below)

Pretests of E are weak. I did not get TLE for the following DFS routine:

void dfs(int u) {
  visited[u] = 1;
  for (int v : g[u]) {
    if (visited[v] == 1) { // cycle and hence do not continue }
    dfs(v); // missing visited[v] == 2 check
  }
  visited[u] = 2;
}
»
7 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

Good contest , just +1 shift was needed i.e D = E , E = F, questions were very good ! den2204

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

Now i have to wait 9 days for comeback (-_-)

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

My friend GreenGrape should teach den2204 how to prepare the pretests. Dear den2204, can you imagine that someone can use map to store the edges and write in the statement, that there are can be absolutely same edges, or at least include it in the pretests.

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

Excuse me, I used C++17 to submit my solution during the competition, but I got Wrong answer. After I tried to use C++11 and C++14, I got Runtime error, so I want to ask this. Why? (My solution involves dividing by zero error)

int vx = (tx - x) / abs(tx - x);
int vy = (ty - y) / abs(ty - y);

C++11 Runtime error on test 6: 48359273

C++14 Runtime error on test 6: 48359354

C++17 Wrong answer on test 6: 48360585

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

    Division by zero is undefined behavior in C++

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

      That is to say, the error of dividing by zero in Online Judge may get uncertain results. Is that true? I always thought that if the pointer is out of bounds or divided by zero, it will return Runtime error, thank you.

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

        Indeed, undefined behavior means at that point the program could do anything completely unexpected (i.e., "undefined"), and it usually varies depending on the computer and the compiler it's being ran on. So it doesn't make much sense to analyze WA, RE, TLE or whatever veredict whenever you're doing undefined operations. Another common one: accessing an array over its defined bounds.

        Sometimes it might be Runtime Error because that sector of memory doesn't belong to you, sometimes it actually does and it's initialized with zeros, some others it belongs to you as well but it hasn't been initialized at all (contains a random value). All of these three cases could happen running exactly the same code.

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

How to solve E if to reverse each edge different controllers are used i.e. minimize the sum of cost all edges we have to reverse?

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

Here's my idea with proof for D: Greedy: Take the king to the centre. Then consider the number of rooks in each of the 4 squares formed by lines passing through the king. Look at the square with least amount of rooks. Walk the opposite way.

Proof: From the center, you can reach each corner in less than 500 moves. The square with least rooks must have number of rooks <= 666/4 by pigeon hole principle. So, there are atleast 500 rooks in the other 3 squares, combined. Now, Dasha has to move >= 500 rooks within < 500 moves, which is not possible. Hence, we are done.

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

Порадовала чисто математическая задача С. Порадовала интерактивная задача D. Расстроили относительно слабые претесты в D и E. Возможно, стоило бы поменять задачи E и D местами.

А так все очень даже хорошо как для первого раунда, так держать den2204!

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

DELETED

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

I have a general question that is kind of related to this contest.

In today's contest there was a solution in my room that solved Problem B using brute force solution with complexity O(n2). The solution was supposed to give TLE on a test that has (n = m = 105) and all the numbers appearing starting from 1 and ending with 105.

I wasn't able to hack this solution due to test case size which was about 512 KB, while codeforces seems to have the upper limit for a test case on hacking set to about 265 KB. Is there a reason for this low limit? Shouldn't it be a little higher? Specially since lately most problems seem to have bounds about 2.105 rather than 105 like before, wouldn't this limit make it harder to hack solutions that fail due to TLE on large test cases?

MikeMirzayanov, perhaps you could kindly provide an answer?

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

It's a shame C and E were well known. I liked those problems. (and I didn't know them, so I couldn't figure out E in time 0w0)

But nevertheless I think it is a good contest! Good job den2204

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

Problem D. Correct submission: 48360170 My contest submission: 48346037 This 1 character cost me 150 rating points (-65 instead of about +90). The worst part in it, that it passed pretests when it is wrong 1 out of 4 times. This should have failed on pretests. But now I am in the same position as people who couldn't solve D. I know that I made a terrible mistake with that x instead of y, but I still have the question: Why does Codfeforces judging system is so unfair? EVERYONE who gets wrong answer on pretest have the chance to correct it, while EVERYONE who passed pretests with a wrong submission will lose ALL of the points for that problem. This is just a game of luck. In My opinion there would be 2 fair way to judge with a similar system. A: There are no pretests, only maintests. That would be much harder to make a good solution, but it would be fair. B: pretests=maintests. This would make a little easier to make a good solution, and it would be fair as well.

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

My wrong submission for D that I skipped during the competition passed system test. Paradoxically I would be first if I didn't come up with correct solution.

Wrong submission: https://mirror.codeforces.com/contest/1100/submission/48362464

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

По идеи у дшки же ведь нет решения. Даша ведь всегда может сходить так чтобы он проирал. Я условие раз 5 перепрочитал. Не понимаю. Обьясните

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

    У меня такой же вопрос был. Я задал во время конеста и предложил следующую страту: Где то находится король, возьмем вертикальную полосу ширины пять, две слева, две справа и вертикаль где стоит король, аналогично горизонтальную полосу. получился крест, расставим ладьи на главной диагонали чтоб они не попадали в крест. Если после хода короля, если ни одна ладья не попала в крест, то стоим на месте, если попала (а может и две сразу) то берем любую из двух или одной и перемещаем как можно дальше от креста на свободную позицию на диагонали, для второй ладьи(если она есть) остается еще один ход для перемещения из креста. Мне сказали что решение всегда есть

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

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

      Корректное решение уже не раз описывалось, так что просто протранслирую на русский.

      За <= 500 ходов можно перейти в клетку (500, 500). Тогда горизонталь 500 и вертикаль 500 разделят всю доску на четыре четверти. Т.к. ладей 666, то минимальное кол-во ладей в четверти не больше 666 / 4 = 166. Пусть мы нашли такую четверть. Тогда все, что нужно — это идти по диагонали в противоположную от этой четверти сторону.

      До угла всего 500 ходов. За каждый ход уменьшаются размеры остальных четвертей. А в них как минимум 666 — 166 = 500 ладей. Итого за 500 ходов обязательно наткнешься на хоть какую-нибудь ладью.

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

I can only handle A,B,C after contest.Bt during contest time I was a great looser

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

There is a problem that harder than F and I revise it wrong :( Actually if I make the array in size 1e6 then I can get Happy New Year :(

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

I wanna ask sth about E, i use the dfn[], get the time when i into a node, but others get the time they leave the node, as a result i get WA, i hope someone can explain it. Thank you so much.

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

Спасибо) Хороший раунд, мне все очень понравилось)

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

I know it's an accident but problem F really coincides with a problem in a training contest proposed by whzzt called "异或"(XOR, in English).

In that problem, you will be given a sequence of n integers a[] and m queries {li, ri, di}. For each query, you need to choose a subset of a[li, ri], compute the XOR-sum of all numbers in this subset and XOR the result by di so that the final result is maximized. You need to output the final result. Constraints: n, m <= 10^6 and 0 <= ai, di < 2^30.

Anyway, D is awesome.

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

In problem E, is there someone like me that easily get a binary search and Topological sorting solution to the answer of worker but failed on the construction of answer of edge?

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

Problem A

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

How to solve e. my idea was do a dfs from a certain node. keep trace of the minimum weight . if a cycle is formed. we will reverse the edge with minimum weight and then again start dfs from the reversed node.

will it work?

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

I think there is a critical test case which was not given in the dataset of problem C. I found a user’s two accepted solution with different output. If I am not wrong then some user may not be able to pass the dataset if this test case is valid. I am giving the test case and the two solutions link below-
Test case: 3 100
First accepted solution
Output of first solution: 646.4101614984
Second accepted solution
Output for second solution: 499.9999999418
Please check den2204

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

Our coach 2778 (rank 448) Rating +24 1876->1900 became Candidate Master ???

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

"Тут мог быть ваш смешной комментарий"

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

Regarding tasks A-D:

A — easy, but you have to state in bold, that i can be any number. Because usually, it is 0/positive.

B — ok, but usually the number of problems would be described as n and would go first.

C — this task is the worst. As I stated in my older comment, it's pure geometry task which takes one line to resolve. There is no algorithm, no space for optimization, just geometry. I believe, that some people just googled it and I'm mad at myself, that I haven't done it also and spent the time to solve this task.

D — OK

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

    I think you did the right thing.

    I could have searched up both C and E and instantly solved them. But I didn't. I don't think you should be mad for putting an earnest effort in a contest; looking for solutions on google will never help you develop problem-solving skills. The people who just googled it are doing themselves a disservice, and I question why they even do codeforces.

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

      Yeah. I wouldn't google E or any coding task during the contest. But solving C didn't help me in terms of my coding problem-solving skills. The problem is interesting because you need to see, that if you connect centers of external circles, you've got regular polygon. But it's nothing to do with programming(((. Maybe I'm more disappointed, that I've spent time on this task instead of solving D faster.

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

.

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

Can someone please explain me how is Idleness limit calculated?

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

den2204 will there be an editorial?

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

Someone can explain me how to solve B with a time complexity of O(m) and not O(m*n) ?

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

    If you loop the O(m) elements and keep track of a frequency array you can realize at each point you can either

    1) hit a contest — O(n) update

    2) not hit a contest — O(1) update

    Seems like O(n*m) right? Nope!

    Observation: you can hit a new contest up to O(m/n) times. In total hitting a contest can only contribute (m/n)*(n) = O(m) to your complexity. So actually the overall complexity is O(m), regardless of n. This is the basic idea behind amortized analysis: looking at worst case of how much each operation contributes instead of the whole algorithm. It is very likely you already thought of this solution in contest!

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

      Can you please explain more, how exactly can I identify these types of problems?

      And if you don't mind can you explain why my solution gives a TLE, I thought of a very similar approach.

      https://mirror.codeforces.com/contest/1100/submission/48354732

      Thanks a lot for asking, I am just getting started with CP!

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

        Your code is O(nm) because your loop O(n) everytime you check a new element. You want to only loop O(n) when you hit a contest, which would make overall code O(m).

        for (int i = 1; i <= n; ++i) {
            if (ar[i] == 0)
                return false;
        }

        Instead of this you want to keep track of "how many cnt[i] > 0" which can be done by updating every time you add or subtract.

        My code

        How to identify these problems?. Intuitively, you know you should analyze complexity more carefully when the algorithm does a heavy operation rarely. Here is works out nicely, because the O(n) update is infrequent enough so that it is linear overall.

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

i am sorry if this comes across hateful, but this isn't an interdisciplinary contest. why did we get maths in this contest? i think there was a misunderstanding somewhere. can we get a rating compensation for this? doesn't seem fair ..

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

Автокомментарий: текст был обновлен пользователем den2204 (предыдущая версия, новая версия, сравнить).

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

Auto comment: topic has been updated by den2204 (previous revision, new revision, compare).

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

Автокомментарий: текст был обновлен пользователем den2204 (предыдущая версия, новая версия, сравнить).

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

Auto comment: topic has been updated by den2204 (previous revision, new revision, compare).

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

Why problem Div2 C has "Binary Search" in tags?