PikMike's blog

By PikMike, history, 5 days ago, translation, In English,

1167A - Telephone Number

Idea: Roms

Tutorial
Solution (Roms)

1167B - Lost Numbers

Idea: Vovuh

Tutorial
Solution (BledDest)

1167C - News Distribution

Idea: MikeMirzayanov

Tutorial
Solution (BledDest)
Solution (PikMike)

1167D - Bicolored RBS

Idea: adedalic

Tutorial
Solution (adedalic)

1167E - Range Deleting

Idea: Roms

Tutorial
Solution (Roms)

1167F - Scalar Queries

Idea: adedalic

Tutorial
Solution (adedalic)

1167G - Low Budget Inception

Idea: adedalic

Tutorial
Solution (adedalic)
 
 
 
 
  • Vote: I like it  
  • +47
  • Vote: I do not like it  

»
5 days ago, # |
  Vote: I like it +32 Vote: I do not like it

Editorial of F is soooo goooooddd. thx man

»
5 days ago, # |
Rev. 4   Vote: I like it +19 Vote: I do not like it

F is a little overcomplicated I think. Easier way to think about it is to see that every contribution of the lower-valued items on the left is that their contribution is just the number of spaces on the left of each of them plus one (if example $$$a_j < a_i$$$ and $$$j < i$$$, contribution is $$$j + 1$$$, since this is the number of intervals that the lower-valued item gets included in). Multiply this by the number of intervals on the right (n - index), since it contributes that many more times. Then easy done. Do this with the segment tree by updating the position index in fenwick tree with itself to get contribution over all of them fast (contribution from left side is query(index) * (n - index)). Then do same thing on the right side. (All values are zero indexed in this explanation)

UPD: Ok, someone has asked for a clearer explanation, so I have taken a little more time to write it out. It is very large, so I spoilered it.

better explanation
»
5 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Please explain problem C .The problem as well as input ,output is not clear to me. How become the output 4 4 1 4 4 2 2 for sample test case ?

  • »
    »
    5 days ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Use some pen & paper, you'll get eventually.

  • »
    »
    5 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Read the problem attentively, you'll understand input & output.

  • »
    »
    5 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Firstly you read the number of people and the number of groups, then for each group you read the which people belong to this group. In then end for each people $$$i$$$ you wish to find the number of people that are share a group with $$$i$$$.

»
5 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Can problem C be solved using DSU data structure ?

  • »
    »
    5 days ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    Yes. Initially, you want to add everyone in a group of friends do the same component. Then, when someone is into another group, you connect the components.

    This is exactly what the editorial says in the last line.

»
5 days ago, # |
  Vote: I like it +1 Vote: I do not like it

I'm really sad that this is the first time I did an interactive problem and the tutorial in the contest show fflush(stdout) to flush output in C++. I kept getting idleness error in the contest and couldn't figure out why (WA is much easier to deal with). After this editorial released, I changed fflush(stdout) to cout.flush() and I could debug my old code in a blink. You guys should update the tutorial for the interactive problem. It was frustrating.

»
5 days ago, # |
  Vote: I like it +4 Vote: I do not like it

The link to this blog has not yet been mentioned in the contest page. Should you not add it to the contest page as soon as the editorial is published? Just asking.

»
5 days ago, # |
  Vote: I like it 0 Vote: I do not like it

For Lost Numbers I used almost the same trick.But struck with one problem.I was using GCD to get to know unique number but it turns out that it is not.let say the array is [a,b,c,d,e,f] and x=a*b and y=b*c .So GCD(x,y) should give me "b" but i was getting multiple of b.So is there a way to resolve this issue.Thanks is advance.

  • »
    »
    4 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    gcd(x,y) gives you b only if gcd(a,c)=1. Otherwise, it will give you gcd(a,c)*b, which is a multiple of b.

»
4 days ago, # |
  Vote: I like it 0 Vote: I do not like it

The explanation to the solution of problem C is not very clear. Can someone explain the approach in simpler words ?

  • »
    »
    4 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Use a DSU to connect all of the groups. This can be done in O(group size) for each group by connecting the first person in each group to everyone else. Then find the size of the group each person is in to get the answer.

»
4 days ago, # |
  Vote: I like it 0 Vote: I do not like it

I managed to pass G with 2 pointers (breaking early helped a lot). I do prefer the editorial solution though. Thanks!

  • »
    »
    3 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Why is it enough to maintain 7000 positions to the left and right?

    • »
      »
      »
      3 days ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      Oh, I totally forgot to mention this in editorial. Basically, positions further than that won't ever be needed. Check the angle you get for the closest collision between a building and a ray. It's less or equal to $$$arctan(\frac 1 {3500})$$$. Find the maximum $$$x$$$ such that $$$2 arctan (\frac 1 x) > arctan (\frac 1 {3500})$$$ so that two buildings collinding produce greater angle. That $$$x$$$ is 7000, thus further collisions will never affect the answer.

»
3 days ago, # |
  Vote: I like it +8 Vote: I do not like it

Can someone explain the editorial of problem E (Range Deleting)?
Having a difficult time to understand it or is there any other approach which is simpler and easy to explain.

»
2 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Hello, I solved Problem C using DFS in Java. I saw one "Accepted" submission in GNU C++ with the same logic. I am getting time limit exceeded on test case 6. I have tried to speed up the code as much as possible. Is it possible that the same solution in Java gives a time limit but not in GNU C++?

  • »
    »
    3 hours ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Whenever your program might go in deep recursion or dfs you might get RunTime Error. This is due to StackOverFlow Error. As stack size of Java is very low, hence, either you should avoid deep recursion and use iteration or increase stack size dynamically.

    Source :

»
7 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

May you attach this tutorial link to the contest material section?

It might really be a mess (a search will work :3) for future participants to look for it (for practice).

»
90 minutes ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Problem F

Many people got WA on test 35 (me too) as we didn't mod while adding inside BIT