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

Автор Leftist_G, 8 месяцев назад, По-английски

Thank you for participating and accompanying Simons! We hope you enjoyed the problems.

Rate the contest!
Rate the difficulty!
Rating Predictions

2205A — Simons and Making It Beautiful

Rate the problem!

Author: StayAlone

Solution: StayAlone

Hint 1
Hint 2
Tutorial
Code (C++)

2205B — Simons and Cakes for Success

Rate the problem!

Author: Leftist_G

Solution: Leftist_G

Hint 1
Hint 2
Tutorial
Code (C++)
Code (Python)

2205C — Simons and Posting Blogs

Rate the problem!

Author: Leftist_G

Solution: Leftist_G

Hint 1
Hint 2
Tutorial
Code (C++)

2205D — Simons and Beating Peaks

Rate the problem!

Author: cool_milo

Solution: cool_milo, Leftist_G

Hint 1
Hint 2
Hint 3
Hint 4
Tutorial
Code (C++)

2205E — Simons and Dividing the Rhythm

Rate the problem!

Author: Leftist_G

Solution: Leftist_G

Hint 1
Hint 2
Hint 3
Tutorial
Code (C++)

2205F — Simons and Reconstructing His Roads

Rate the problem!

Author: cool_milo, Leftist_G

Solution: cool_milo, StayAlone

Hint 1
Hint 2
Tutorial
Code (C++)

2205G — Simons and Diophantus Equation

Rate the problem!

Author: Leftist_G

Solution: cool_milo, LiHn, liuhangxin, Leftist_G

Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Hint 6
Hint 7
Hint 8
Tutorial
Code (C++)
Разбор задач Codeforces Round 1083 (Div. 2)
  • Проголосовать: нравится
  • +110
  • Проголосовать: не нравится

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

Maybe my skill issue but C killed my back implemented D and got short just 1 minute :(

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

Hello,I‘m the provider of D and F,and I also helped with some G issues :D, thanks again for everyone who participated in this round! Please rate the problems carefully >_<

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

I have a nice solution to D, and I didn't completely get the editorial one so I will write it.

let's observe that in the end the array is decreasing and then increasing so let's see what happens if i is the index of the turning point.

I claim that I keep the indices of the monotonic stack when it's get to i, both from the left and right side, the dec monotonic.

why is that true you ask?

well let's call the next one bigger than i from the right j, such that of course j>i lets say that j is not in the final array, therefore I popped it with something bigger than it, this can go on but the point is there is an element in the final array which is bigger than the value in index j, so therefore I can just bring j back, there isn't something between i and j that is bigger and everything which is between j and the one which is bigger than him have to have been popped because j is gone so on for every index of course and the left side

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

I did so much extra work with A (cry). Could've saved some time there if I could've thought straight, but it is what it is.

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

This is the first time the DBOI team has prepared a contest on Codeforces — and probably the last. We spared no effort, and preparing this contest really took a lot of time. The contest would not have been possible without everyone’s help, including those who contributed problems (even the rejected ones), helped with testing, and of course our coordinator.

Hope you enjoy the contest, and we truly appreciate your advice and feedback.

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

Hi, I believe Task D is similar to a standard CSES task i.e. Mountain Ranges.

It can be solved via Dynamic Programming + Monotonic Stack/Range Query Data Structures too!

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

    Recurrence is similar. I have previously solved Mountain ranges and thus got a deja vu feeling while solving today's D. But the main part is to deduce that we need to find the longest V shape in the array.

    I think it's a good enough manoeuvre to appear in a rated round.

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

      True! I do agree the task is nice, especially the fact that once one observes that there can be only one valley (or an upward/downward slope), it's essentially maximising it's length (and subsequently minimising number of operations).

      The Mountain Ranges reference hit me because it felt oddly related, overall a decent task for sure!

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

      By longest V you mean longest decreasing subsequence ending at i + longest increasing subsequence starting at i right? Or am I missing something?

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

fun fact about F: every planar graph has a dual, and some graph theoretic properties in the primal graph become other graph theoretic properties on the dual graph. for example, an Eulerian subgraph (all degrees are even) in the primal corresponds exactly to a cut (coloring the faces 0/1) in the dual. it turns out that thinking about the dual graph in this problem makes the weird alternating sum formula and the connectivity constraints a lot more intuitive (at least for me).

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

D can be solved using a stack+dp too!!

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

I have an alternate and possibly easier solution for D. For array to be cool, note that it has a fixed minimum element and the array is decreasing before that and increasing after that.

Fix the index of the minimum element (i) and now think how will the array look. Focus only on the subarray left of i. Note that the maximum element ( call its index l) in this range will be the first element of the final array. With some thought, it can be seen that the next element in the final array will be the maximum element in the range (l,i) and so on... . Same thought can be applied to the array at the right of i. The implementation turns out to be easy.

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

Congratulations to the setters for a flawless round ! Here is my opinion about each problem:

A
B
C
D
E
F
  • »
    »
    10 дней назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Can some one explain why problem C wont give tle,In my opinion it should give tle cause the many accepted solutions have O(n^3 log(n)) time complexity

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

      Do you have a link to such a solution ? Note that the sum of $$$l_i$$$ is $$$\leq 3000$$$ too.

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

Another (probably) unintended solution for D: Go through the elements x in increasing order. If one of the neighboouring elements is bigger, we are done with x its cost is 0. Otherwise, you need to remove all elements adjacent to x on one side untill you reach a bigger element. It is optimal to take the direction with the minimal number of removed elements minus the sum of their costs, so whenever our final array contains x we know which direction to go to. We can then set the cost of these removed elements to 0, and set the cost of x to the number of removed elements, since every valid array containing those smaller elements would also contain x, but then it would be optimal to delete them so x has a bigger neighbour. Our total cost is the sum of the elements of the array. TO get the sum of a segment and set all elements in a segment to 0, we use a lazy segment tree.

Implementation: https://codeforces.me/contest/2205/submission/364533929

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

shouldn't something like this be possible in problem F? (i'm assuming i misread/misunderstood the problem)

(the number adjacent is the degree)

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

C was tough!

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

Problem C can also be solved using pointers.
Implementation : 364562915

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

Really nice contest. Tried solving C first. Got cooked :(

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

Not bad CN, it breaks my bad impression of CN.

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

C>>D imo. Spent ~30 mins on thinking about a greedy of C but used only ~3 mins to come up with a solution of D(The spent only 4 mins on it).

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

Cannot believe B has so many AC. Thanks for the contest though.

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

Check out my submission for G: https://codeforces.me/contest/2205/submission/364629640

It is quite a bit shorter than the editorial code. I also did inclusion-exclusion in a bit of a weird way: we only want to subtract $$$d$$$ such that $$$d$$$ does not divide $$$n$$$. Hence we can skip $$$d$$$ such that there is a $$$p | n$$$ such that $$$p^e$$$ divides $$$d$$$ but $$$p^e$$$ does not divide $$$n$$$ for some $$$e \gt 1$$$. (you can figure this out without factoring $$$n$$$!). Then we multiply by $$$\mu\left(\frac{d}{\gcd(d,n)}\right)$$$. So you can get away with not computing some $$$f(T)$$$, where either T fails the above checks, or $$$\mu\left(\frac{T}{\gcd(T,n)}\right) = 0$$$, although this is only a constant optimization.

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

Why does my $$$O(n^3)$$$ solution pass for C?

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

Sharing a very USER-FRIENDLY solution of C

http://codeforces.me/contest/2205/submission/364637515

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

In problem G, how to show the complexity of "naively save the intervals, sort them, and then apply two pointers" method is $$$O(m \log ^2 m \log \log m)$$$ ?

I also read jiangly's code (364548110) and I believe he used this method. Maybe I misunderstood the process of this method?

My approach on the complexity
  • »
    »
    8 месяцев назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится +5 Проголосовать: не нравится

    I submitted liuhangxin's testing code at here. I considered and analysed his code for the conclusion that the complexity of the method is $$$\mathcal O(m\ln m\log m\log\log m)$$$.

    I think the process is, for both $$$d_1T$$$ and $$$d_2T$$$, valid $$$j$$$-s distribute in $$$\mathcal O(\log m)$$$ uncrossed intervals, and we just need to calculate the number of $$$j$$$-s covered by two intervals. I think that if we sort the two sets of intervals independently, this can be completed using two pointers in linear complexity. Thus, the whole complexity is $$$\mathcal O(m\ln m\log m\log\log m)$$$.

    I guess liuhangxin's method is a "symmetrical" method with jiangly's, according to your description. Could you please try understanding the method above?

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

      I think liuhangxin's testing code actually used some non-trivial ways to sort the intervals. This code first sorted all $$$dT\ \mathrm{xor} \ m$$$ and then directly construct the list of sorted interval endpoints (which will be stored in tmp) using function void get(int l,int r,int d). And I believe this code is $$$O(m \ln m \log m)$$$ time, as the construction actually runs in the same logic as the solution using trie.

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

can anyone tell me what is wrong in my solution for problem C : 364542311

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

For C my code does work but I have strong intuition that its O(n^3 * log(n)) that shouldn't pass can someone help me figure out what's happening

Here is my code: ~~~~~~

include <bits/stdc++.h>

using namespace std;

void solve() { int n ; cin>>n; vector<vector> v(n); for (int i = 0; i < n; i++) { int l ; cin>>l; vector temp(l); for (int j = 0; j < l; j++) { cin>>temp[j]; } reverse(temp.begin(), temp.end());

map<int, int> local_seen;
    for (int x : temp) {
        if (!local_seen[x]) {
            v[i].push_back(x);
            local_seen[x] = 1;
        }
    }
}

sort(v.begin(), v.end());

map<int, int> visi;
for (int i = 0; i < n; i++) {
    for (int j=0 ; j<v[i].size(); j++) {
        if (!visi[v[i][j]]) {
            cout << v[i][j] << " ";
            visi[v[i][j]] = 1;
        }

    }
    for (int j = i+1 ; j<v.size(); j++) {
        vector<int> current; map<int,int> seen;
        for (int x = 0; x<v[j].size(); x++) {
            if (visi[v[j][x]] || seen[v[j][x]]) {
                continue;
            } else {
                current.push_back(v[j][x]); 
                seen[v[j][x]] = 1;
            }
        }
        v[j] = current;
    }
    sort(v.begin() + i+1 , v.end());
}
cout<<endl;

}

int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { solve(); } return 0; }

~~~~~~

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

what does It's noticed that the maximum number of each number cannot be moved even mean in the problem D tutorial?

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

F is awesome!