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

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

1624A - Плюс один на подмножестве

Идея: MikeMirzayanov

Разбор
Решение

1624B - Сделай АП

Идея: ibraevdmitriy

Разбор
Решение

1624C - Деление на два и перестановка

Идея: MikeMirzayanov

Разбор
Решение

1624D - Раскраска палиндромов

Идея: ibraevdmitriy

Разбор
Решение

1624E - Маша-забываша

Идея: Aris

Разбор
Решение

1624F - Интеракдивная задача

Идея: Vladosiya

Разбор
Решение

1624G - Дерево минимального ора

Идея: Vladosiya

Разбор
Решение
Разбор задач Codeforces Round 764 (Div. 3)
  • Проголосовать: нравится
  • +90
  • Проголосовать: не нравится

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

How is problem G only of 1900 difficulty? It's a really nice problem, but in my opinion it is way harder than problem F.

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

    More people solved G, difficulties are calculated dynamically from the number and ratings of the people who solved it in-contest.

    I think it's because G is a bit easier if you have a DSU implementation and have solved similar problems before (Kruskal's algorithm), while you have to be very careful when implementing F to ensure the modified binary search is correct, especially as it's harder to locally test interactive problems, generally speaking.

    Of course, there is some variation/subjectivity in which problems individuals may consider easier or harder.

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

      Spheniscine Can you explain why we start with the highest bit first rather than the lowest and then choose the next higher bit to check for it's feasibility in the final answer?

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

        Comparing two numbers is like comparing their bitreps in lexicographic order, higher bits take priority

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

          Thanks for the reply, I understood the thing you said about the higher bit taking the priority. Since if one number has a bit ON and the some other has that very bit OFF than we don't really care about the bits on the right side. But I am not able to understand that why in this very particular problem we can't go from bit 0 to bit 30. Is it not consistent with the submasking procedure. Or is there something else? Am I missing some fundamental theory knowledge for submasking?

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

            Because there is a step where you keep only the edges with $$$k$$$-th bit $$$0$$$ if it won't disconnect the graph. Trying to do that the other way won't work, as then you'd give the lower bits priority over higher ones.

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

            I'll try to explain why we cannot go from 0 to 30.

            Let's say you are going from 0 to 30. Since you need to minimise the ans you try to make the current bit 0. So, let's say you reach a point ??000 where the last 3 bits have been assigned greedily to minimise ans. But, now there can be a possibility that the answer will be 11000. Whereas there is also a possibility that if you choose ??011 when going from 0 to 30, you end up with 00011. So, greedy won't work if we go from 0 to 30.

            But, let's say that we go from 30 to 0. Now, if greedily, we take 000??, then it doesn't matter what next bits we get. By taking any option other than greedy will never give you better answer.

            if this is still not clear, let's do some calculations.

            We took 000?? which means that the first 3 bits are 0. This we took greedily. In worst case, next two digits will be 1. So, answer is 00011.

            Now, for first three bits, what other choices we had? 001??, 010??, 011??, 100??, 101??, 110??, 111??. Even if you replace all ? with 0 now, they will all be greater than 00011. Hence, greedy works.

            Note that 2^x > 2^(x-1) + 2^(x-2) + ... 2^1 + 2^0.

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

    The problem G was much easier for those, who tried to solve it. It even required some observation or luck to skip E and F during the contest to go for it! I think that if the problem G was swapped with E, then it would have had even more successful submissions and even lower estimated difficulty.

    It is also not the first obvious and easily solvable DSU library problem on Codeforces. We already had a similar D. Social Network problem (rated as 1600) during the recent Deltix round.

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

Has anyone done C with graph matchings like the tag mentioned, if yes, kindly share your code

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

Would D be solveable if I binary searched on the answer and tried to construct k palindromes using the counts for each character?

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

omg i thought G is xor and got stucked... so any idea if we need to minimize the xor sum?

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

What does interacdive (problem f) mean?

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

A greedy solution for C works as well.

  1. Sort the input array.
  2. Iterate from backward and try forming the largest element not yet formed <= n with it.
»
5 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Can somebody please give proof of the problem C solution?

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

Complete overkill solution of C using maximum bipartite matching:

Create a graph with $$$2n$$$ vertices. First $$$n$$$ of these vertices represent the permutation points and the next $$$n$$$ represent the array elements. Draw an edge to all permutation points reachable from all elements of the array ($$$O(n \log A)$$$ such edges). Now run maximum matching on this graph. Answer is yes if the number of edges in the matching is $$$n$$$ and no otherwise.

Submission : https://codeforces.me/contest/1624/submission/142329187

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

After a long, long time, the editorial of this round was published!

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

Can somebody help me with F please. I tried to bruteforce all the numbers in the range [1,n] in O(n). I added the same number to the array elements that I queried the judge. After receiving the query, I just marked all the numbers which didn't match the query value. I agree the approach isn't good because I ended up with more than one number in some cases. I still think it isn't totally wrong. Can somebody help me in either correcting my solution or proving that I cannot get an AC with this approach? 142283459 As always, I will be grateful. Thanks in advance.

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

1624G — MinOr Tree https://codeforces.me/contest/1624/submission/142429144 Why it is giving TLE?

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

Can someone explain why the greedy solution for problem C always works?

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

    Can u please describe what exactly the greedy solution that you are talking about?.

    I think it is forming larger numbers in permutation first then looking for smaller numbers.

    It is mainly because, if you are able to get a number i from x indices and number j from y indices where 1 <= i < j <= n and you get i in the sequence when you are continuously dividing j by 2. Then you can say that x >= y because every index that can produce j can also produce i and some extra indices can produce i but not j. If you use indexes that are able to produce i first then you might left out with indexes that can produce i but not j. then you may not produce j . So it is better to produce j first then i next.

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

If you are looking for video solutions, you can find them Here (All Problems)

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

Pls can somebody tell why this solution 142368820 for problem E is not giving TLE and what is its correct time complexity. I think its time complexity is greater than O(n*m*m) (not sure). Any suggestion will be helpful. Thanks.

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

    I think your code luckily passed testcases . The complexity of your code is o(m *n * m). You have to do some precomputation of storing all possible 2 length or 3 lengths sub-strings possible from given n strings but instead of that you are iterating all the n strings when ever you want to know whether t is possible to make or not , which is adding a factor of o(n*m) which is actually can be done in o(1).

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

Problem G. MinOr Tree https://codeforces.me/contest/1624/submission/142442799 . Why this java solution is giving TLE?

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

Problem C Can anybody tell me where i'am doing wrong (Getting WA at 4628th token) 142461170

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

1624G — MinOr Tree https://codeforces.me/contest/1624/submission/142528765 Why it is giving TLE?

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

can someone pls explain the sort fn problem c soloution "sort(a.begin(), a.end(), [] (int a, int b) { return a > b; });"

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

    std::sort accepts a starting pointer, end pointer and a function according to which it will sort it. This function should take two inputs (for example a and b) and return true if a should come before b. [](int a, int b) {return a > b;} is short form for a function(also known as lambda). So basically all the statement does is sort a in descending order

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

Can anyone tell me why this solution 142543258 for E is giving TLE where this one 142542275 that I came across not giving tle.

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

Can someone please explain the approach of problem B !

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

Amazing round! Any tips on how to get better?

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

Why am I getting Memory Limit Exceeded in this ?: (problem E)

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

Problem C can be solved using sorting only : 142623720

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

Can somebody please give proof or more detailed explain of the problem D solution?

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

Can some one help me with this G-MinOr Tree?

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

For Problem G, why is it TLEing on test 42? Submission: 240490794

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

those who are getting WA on test case 2(test case 3648), try this test case

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

here is the python solution

~~~~~~~~~~~~~~~~~ t = int(input())

for i in range(t): n = int(input()) li = list(map(int,input().split())) result = max(li) — min(li) print(result)

~~~~~~~~~~~~~~~~~~ It's so easy.

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

seven