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

Автор BledDest, история, 8 лет назад, По-русски
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
  • Проголосовать: нравится
  • +42
  • Проголосовать: не нравится

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

Problem E is not original! link

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

I had a different idea for E.

First, let's take the vertices whose degree is bigger than N/2. Any two such vertices must be in the same connected component, because their neighbor sets must overlap.

What about the other vertices? Well, their degrees are smaller than N/2. That means that N-deg(v)>deg(v) for each of them. but the sum of N-deg(v) is at most 2M, hence their sum of degrees is at most 2M as well. So we can apply a regular algorithm (dfs, or dsu) to those vertices.

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

someone know why i get RE on Test 9 by using it=vis.lower_bound(*it) ,setvis for unvisited node and auto it=vis(iterator) 34911809

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

someone know why i get Re on test9 by using it=vis.lower_bound(*it) ,

set<int>vis,it=vis(itertator) 34911809 ,I get AC after changing *it to x (int x=*it)

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

Editorial for E looks unfinished.

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

Can someone explain G?

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

Что за рюкзаковая динамика? В интернете не находится ничего адекватного по этой фразе.

Неужели трудно сделать разбор задачи чуть подробнее, видя что решили её единицы, при том что она на уровне сложности D.

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

For Problem E,can the problem be solved in the same complexity if the graph is directed?

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

In first string of problem G you have a little mistake. Not gcd(z, y) = 1 but gcd(z, p) = 1

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

For F, you can do it with a BIT and a set. Store sums in the BIT, then for range updates, you can store the indices of all numbers that aren't 2 in the range in the set with lower_bound and traversing forward. If you set something to 2, erase it from your set.

The solution is still O(qlog n) but should be easier/faster to code.

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

Can someone share their model solution to F ? I am not able to understand most of the codes.

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

Hi guys, I'm having trouble with problem F.Here is my solution .I did everything that was written in editorial but my solution doesn't fit time limit in test case #69. Moreover, it works on other testcases ~1900 ms. Can somebody give me some pieces of advice?

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

Can someone explain to me G-List Of Integers a bit more detailed? I don't understand the editorial solution

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

    Well, the main difficulty is that you have to be familiar with inclusion-exclusion principle.

    Let's use binary search to find the answer. Then we need to somehow calculate the number of good integers (good integers are coprime with p) from integer x to integer mid (the middle element in binary search). It's better to rewrite it as count(mid) - count(x), where count(x) is the number of good integers not exceeding x.

    Now we somehow have to calculate this count(x). We need to find all good integers from [1, x]; these are all integers from [1, x] excluding those that are divisible by some prime divisor of p. To find the latter, we use inclusion-exclusion principle: let our sets A1, A2, ..., An be the sets of integers divisible by the first, the second, ..., the n-th prime divisor of p. And then we apply inclusion-exclusion formula as it is — since the maximum number of primes in factorization of p is 7, then we can just iterate through all possible combinations of these sets A1 ... An.

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

Can inclusion-exclusion be used to calculate euler's phi function? Won't it be a special case of it?

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

    Well, actually if we set in A(p, y) mentioned in editorial p = y, then we will get exactly φ(p). So I believe Euler's function can be calculated using inclusion/exclusion, it's just not convenient to do it this way.

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

I just wrote the same solution described in editorial and got TLE http://mirror.codeforces.com/contest/920/submission/34930869

Is the constant factor bad, or have I misunderstood something?

Nevermind, I'm doing range updates wrong.

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

    The thing is that you can't just try updating each of the indices from [l, r] if you have REPLACE query.

    You have to use the segment tree for your updates. It is difficult for me to explain. You have to make the queries in a similar manner to mass change queries in segment trees, but instead of pushing some values you need to do the following if you have to update the whole segment:

    1) If the maximum element on this segment is 1 or 2, then just stop updating the segment, you don't need to do anything in it.

    2) Otherwise, if the segment contains more than one element, divide it into two segments (just the way segment tree does it) and try updating these segments.

    I think that our implementation may help. Take a look at how we have written upd function.

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

Can someone please explain the editorial for problem D. I don't understand it.

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

In problem D, how can we handle cases like 3 5000 0 10^15 10^15 10^15 when we cant remove enough water to get V because 1 ≤ cnt ≤ 10^9.

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

I think the SPJ of problem D has a bug, because on testcase 5, an output like this YES 2 6 5 2 6 4 2 6 3 2 2 1 3 2 6 reports wrong answer, but actually it is correct.

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

F can be done by just using a BIT and std set. Use the set to keep track of the numbers that have not yet become 1 or 2 (so it serves the same function as the max segment tree) and use the BIT to query range sums.

Edit: Somebody already suggested this

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

Problem F Sum and Replace taught me a lot ! If the update function converges rapidly, then we can just keep a max tree and ignore the nodes which have already converged. In the worst case, we will do 6 O(n) scans !

It's a powerful idea, which can be applied to this SPOJ question too, which also has a rapidly converging update function.

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

I used DSU to solve problem C. =)))

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

Used ordered set instead of seg tree beats in 920F - SUM and REPLACE got TLE on tc39 :(
My submission: 93546773
The run time is bound by 6*N for the ordered set operations and maxnLgmaxn for preprocessing

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

https://mirror.codeforces.com/contest/920/submission/272617937

Can someone please guide me where does the solution go wrong?