Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

# | User | Rating |
---|---|---|

1 | tourist | 3434 |

2 | Petr | 3353 |

3 | OO0OOO00O0OOO0O0…O | 3314 |

4 | fateice | 3306 |

5 | Um_nik | 3286 |

6 | Syloviaely | 3274 |

7 | dotorya | 3145 |

8 | LHiC | 3114 |

9 | Radewoosh | 3098 |

10 | mnbvmar | 3096 |

# | User | Contrib. |
---|---|---|

1 | tourist | 178 |

2 | rng_58 | 166 |

3 | Petr | 156 |

4 | csacademy | 155 |

5 | Swistakk | 149 |

5 | lewin | 149 |

7 | Um_nik | 142 |

8 | Errichto | 141 |

9 | matthew99 | 138 |

10 | Vovuh | 136 |

10 | ko_osaga | 136 |

10 | PikMike | 136 |

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial is loading...

Tutorial of Технокубок 2018 - Отборочный Раунд 1

↑

↓

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jun/21/2018 20:46:19 (d2).

Desktop version, switch to mobile version.

User lists

Name |
---|

Div 2 B http://codeforces.com/contest/861/submission/30468001

Can authors share the generator of testcase #36 in problem E?

It seems heavy-light decomposition and some other solutions perform really bad on this testcase.

It is just full binary tree with

n= 500000.Thanks.

I tested this case (

p_{i}=i/ 2) during the contest. And my solution finished in ~1.2s. But I found the solution is 3 times slower if I shuffled the labels of vertices.It is so strange because I think the total operations in segment tree/Fenwick tree are same.

UPD: If I visited the vertices in order, two consecutive operations will share many positions in Fenwick tree. These positions will be fetched in the cache. So it could be much faster than visiting the vertices randomly.

Well, I've got an OK-submission with HLD which performs in 1.3 seconds on this case: 30478628.

Or you can check out cdkrot's HLD submission 30469620 which does it in 1.152 s.

Thanks. I will try to learn from your codes.

I try to random shuffle array "by_h" in your code (like what my solution did during the contest). This submission got TLE. I think this result is surprising to me.

So It's really important to make your solution cache-friendly :D

Strange but true ¯\_(ツ)_/¯

Can someone please provide a more detailed explanation of Div2 D and their C++ code for reference? I know a Trie is to be used but I'm not able to implement it correctly.

i didn't use trie just binary search works here :)

http://codeforces.com/contest/861/submission/30487025

i have stored all the distinct possible substrings formed from the each string...and then just sort this and finding which of the substring occured exactly once :)

You can store each prefix in the trie first and then for each substring you remove the contribution of the present string and then see if the trie has any such substring. You just print the smallest substring which is not in the trie. My solution: http://codeforces.com/contest/861/submission/30489173

Hope this helps :D

Can you explain me this part please "and then for each substring you remove the contribution of the present string and then see if the trie has any such substring" i will be highly thankful to you.

In my code, take a look at the last loop. The outermost loop traverses the strings one by one. For each string, I first remove all its substrings from the trie(If they were present then I will be taking them into consideration too, but I wanna check if any OTHER string other than my current string contains the substring or not). So, I remove all substrings of the current string, see if a substring is present in the trie and then again insert all the substrings of my current string. In case its still unclear, "current string" refers to the ith string I took, i.e, v[i].

I didn't get why in Div2 B problem the quantity of the flats on each floor is in [1,100], may someone explain please?

Because in worst case maximum flat number will not be greater than 100. Then maximum floor quantity will not exceed 100.

OK, but what about this sentence in the statement "Polycarp don't remember the total number of flats in the building, so you can consider the building to be infinitely high (i.e. there are infinitely many floors)"?

Oh, sorry, there was a mistake. I wanted to say "Then maximum flat quantity on each floor will not exceed 100."

The condition about infinitely high building is no matter for you, because even if there is only one flat on each floor, maximum floor index we are interested in is not greater than 100 (and, of course, it is not getting greater with more flats on each floor).

I approximately got it. My mind closes some times :), so I'll back to this problem later.. Thank you very much.

Here's a solution for div1e with just "brute force".

The first step is to make the first observation in the tutorial. Let's consider a naive way to compute the value.

We'll process all nodes with the same depth simultaneously.

For each previous depth's nodes, let's suppose we have computed the number of children at the current depth that we are considering (I will show how to keep track of this later).

For each node, we can naively iterate through its parents and add this stored value.

To update the values, we can also do this naively. More specifically, for each node and ancestor pair, we will update the ancestor's value by adding number of children of node and subtract 1 (we subtract 1 since we no longer want to consider the current node, and we add number of children of this node to represent children at next depth).

Of course, this solution is n^2. We can speed it up to pass with just two optimizations.

With these two simple optimizations, the running time becomes O(n sqrt n)!

short justificationBasically, the idea is we are only keeping track of nodes whose sets of children at depth d are different, and for a particular node, you can show there are only at most O(sqrt n) parents. To prove this, we can think about how many nodes we need to get a new parent with a different set of children at the current depth.

Here's a sample implementation with those two optimizations: http://codeforces.com/contest/860/submission/30449695 You can note that it's basically brute force but with these line added in various places:

could someone help me with problem D : my submission id is 35750991, it is showing runtime error, but dont know why.

I think in the set called val in your code sometimes it could exceed it's initial size which is 70707 in this instruction val[mp[d]].insert(i); like if we have zeros in the the given numbers more than 70707