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

Автор Vladosiya, история, 23 месяца назад, перевод, По-русски

1980A - Генератор задач

Идея: Vladosiya Разработка: Vladosiya

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

1980B - Выбор кубиков

Идея: ibraevdmitriy Разработка: ibraevdmitriy

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

1980C - София и утерянные операции

Идея: ibraevdmitriy Разработка: Gornak40

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

1980D - НОД-последовательность

Идея: myav Разработка: myav

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

1980E - Перестановка строк и столбцов

Идея: ibraevdmitriy Разработка: ibraevdmitriy

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

1980F1 - Разделение поля (простая версия)

Идея: MikeMirzayanov Разработка: Vladosiya

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

1980F2 - Разделение поля (сложная версия)

Идея: MikeMirzayanov Разработка: Vladosiya

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

1980G - Яся и таинственное дерево

Идея: Gornak40 Разработка: Gornak40

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

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

Why is system testing so slow these days?

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

C took 100 lines of code for me :(

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

    It could be done in 20 lines ig

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

    Here is a much simpler solution for Problem C.

    int n; cin>>n; int a[n],b[n]; read(a,n); read(b,n);
    int m; cin>>m; int d[m]; read(d,m);
    if(count(b,b+n,d[m-1])==0) no;
    map<int,int> diff;
    for(int i=0;i<m;i++) diff[d[i]]++;
    for(int i=0;i<n;i++)
    {
       if(a[i]!=b[i])
       {
         if(diff[b[i]]==0) no;
         diff[b[i]]--;
       }
    }
    yes;
    

    The last element of modification array has to be present in D. All the elements which are different in B from A have to be present in D as well to carry out the modification. Except for that any other element in D does not matter because you could be changing that element in A to an intermediate number but then you finally change it to what it is in B.

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

E could be easily solved using set of sets: Solution Link

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

testcasesforces

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

F is Mike's idea :O

But I think you can't avoid sort so the time complexity can't be $$$\mathcal O(n)$$$.

My sol for F:

Find all corners. Remove all corners and run the algorithm for a second time to get a second group of corners.

A fountain becomes a new corner (after one of the old corners is removed) if and only if:

  • it is among the second group of corners; and
  • it is covered by only one corner.

A corner $$$(u,v)$$$ covers the range {$$$(x,y)|x\in[1,u],y\in[v,m]$$$}.

A fountain becomes a new corner after removing the corner covers it.

It's easy to calculate change of area now.

264008397

(Why $$$\{$$$ -> $$${$$$)

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

Can any one help me to understand problem c.? And send solution easly

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

    Our goal is to find whether, given a list of sequential operations, an array could be translated into other or not.

    The only operations that matter here are when an element is changed between a[i] -> b[i]. We ensure all such operations (say, d_k) are actually present in d.

    Since d is also sequential, for any successful transformation, all d_k must be present at the end of d. As for a simple solution, kindly refer one from _Runtime__Terror_ a bit above in this discussion.

    Thanks.

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

dang,how much longerr would the system testing go.

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

Can anyone tell me, in C, why dm must be present in b? I read the question 50 times, still didn't understood.

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

    since you have to apply all operations in the order they are given, then dm will always need to be applied last and there is no following operation that can replace it. Therefore it should appear in the final array

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

YES NO forces

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

Can someone explain why my submission 263986368 on problem c got a tle but something like this 263962017 didn't?

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

problem d, solution 1 — 263972949 failed system test (TLE), solution 2 — 264171599 passed all the tests, code — same in both letter by letter, only difference — solution 1 submitted on Python3 while solution 2 submitted on PyPy3, result — got a "-1" in place of a "+"

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

Problem C solved in C, coincidence or intentional?

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

Can someone explain why my submission 263980440 on problem C got TLE but this submission 264168646 didn't?

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

E can be done with Zobrist Hashing 264181127.

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

For problem E on the basis of the solution, at the end, after sorting both matrix A and B on the basis of rows as well as on the basis of columns, both should turn out to be equal then only our answer is YES. So to simplify my implementation i took the sum of each rows in A and in B in two vectors and finally after sorting checked if both come out to be same and i did same for the columns also, since the sum property should also satisfy since the numbers are unique but i am getting WA on test 2. Can anyone explain what's wrong with my given implementation. I am not able to think on which test case my implementation will fail. please help 264209981

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

When I submitted problem 3 in the contest it showed accepted but right now it is showing TLE on test 10. Can anyone please explain why does this happen ? It has happened with me once before. (I am new to codeforces, so i don't know about all the rules)

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

    You got hacked. (your code failed system testing) This is probably because you used unordered_map or something in your code. See the note at the end on editorial for C

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

Video Editorial for D

https://youtu.be/O2-wL5OXyYc

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

Resources to learn trie?

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

In problem F2 why the following code isn't giving TLE? What is time complexity of the loop for given problem ?

for(int i = 1; i <= k; ++i){
        auto e = a[i - 1];
        if(ans[idx[e]] == 0)continue;
        int tot = total[i - 1];
        int cr = cur[i - 1];
        int lst = last[i - 1];
        for(int j = i + 1; j <= k; ++j){
            auto ee = a[j - 1];
            if(cr > ee.y){
                tot += (cr - 1) * (lst - ee.x);
                cr = ee.y;
                lst = ee.x;
            }
            if(ans[idx[ee]] == 1){
                ans[idx[e]] = tot - total[j];
                break;
            }
        }
    }
»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Problem E is flexible and great mind!The Tuorial only introduce solved way.It's so upset>_<.Can Anyone explain that detailed the reason of way >_< ?

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

Editorial code for C can also be hacked because qsort worst case is $$$O(n^2)$$$: https://mirror.codeforces.com/contest/1980/hacks/1033165

Code

Unexpected verdict means that one of the solutions marked on Polygon as Correct can't pass this test. Vladosiya Gornak40

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

I have no ideas why I got wrong answer on problem G: https://mirror.codeforces.com/contest/1980/submission/264341580. My solution is the same as editorial.

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

Can somebody explain why it doesn't give TLE? I tried fixing each using rowswap and colswap and checked in the end if both matrices are equal or not. Submission

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

I am calculating that same sum of row and columns present in the array B or not

https://mirror.codeforces.com/contest/1980/submission/264546235

I am unable to find where it is failing. Can you tell some test case where it fail.

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

Can anyone help why my code for 1980G - Yasya and the Mysterious Tree is not working?

264619004

264609607

I am happy if any of the above two works.

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

A O(nm) solution for E that uses xor hashes:

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

Did someone solve problem G using Centroid Decomposition?

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

Editorial solution to problem F2 is $$$O(k \log k)$$$ in the general case, but degenerates to $$$O(k^2)$$$ in the worst case (i.e., when all fountains are corners). Here's a truly $$$O(k \log k)$$$ solution: https://mirror.codeforces.com/contest/1980/submission/267832408

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

    Editorial solution checks only the fountains between each two corners, and it never checks same fountain twice. In case of all fountains are corners then second loop immediately terminates (as the next fountain is corner). So, overall complexity is $$$O(K)$$$

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

      That may be true, but we must not forget that the fountain locations are being sorted as a first step, and this takes at least $$$O(k \log k)$$$.

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

        Oh yes, that's true. But I only mentioned the part which causes the complexity to be $$$O(K^2)$$$. But, The overall complexity of the whole code is obviously $$$O(K\log{K})$$$. And also small note, Sorting takes at most $$$O(K \log{K})$$$, not at least, as it indicates the worst complexity.

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

Well, problem C's hacks are extraordinary. Even the author's code gets Time Limit Exceeded on test 156.

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

.