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

Автор Proof_by_QED, 21 месяц назад, По-английски
Rating Predictions

2065A - Skibidus and Amog'u

Problem Credits: chromate00
Analysis: macaquedev

Solution
Code
Rate The Problem!

2065B - Skibidus and Ohio

Problem Credits: cry
Analysis: macaquedev

Solution
Code
Rate The Problem!

2065C1 - Skibidus and Fanum Tax (easy version) and 2065C2 - Skibidus and Fanum Tax (hard version)

Problem Credits: larush
Analysis: macaquedev

Solution
Code
Rate The Problem! (C1)
Rate The Problem! (C2)

2065D - Skibidus and Sigma

Problem Credits: cry
Analysis: macaquedev

Solution
Code
Rate The Problem!

2065E - Skibidus and Rizz

Problem Credits: Proof_by_QED
Analysis: macaquedev

Solution
Code
Rate The Problem!

2065F - Skibidus and Slay

Problem Credits: chromate00
Analysis: chromate00

Solution 1
Solution 2 (Skibidi)
Code (Solution 1)
Code (Solution 2)
Rate The Problem!

2065G - Skibidus and Capping

Problem Credits: larush
Analysis: Proof_by_QED

Solution
Code
Rate The Problem!

2065H - Bro Thinks He's Him

Problem Credits: Proof_by_QED
Analysis: efishel

Solution
Code
Rate The Problem!
Разбор задач Codeforces Round 1003 (Div. 4)
  • Проголосовать: нравится
  • +38
  • Проголосовать: не нравится

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

First time I tried competing in Rust. Hopefully next time will go better. Thanks for the round!

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

Auto comment: topic has been updated by Proof_by_QED (previous revision, new revision, compare).

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

That was not Div4......

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

I'm sure exactly zero people used the Auxillary Tree method to solve F.

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

Problems really weren't newbie-friendly. The problems are excellent, but not for Div.4 contest. More like Div.3 — Div.2

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

    This was my first ever competition other than the one i gave previously. First Div 4 competition. And the first and second problem were i mean pretty easy. The third problem was tough though i was able to solve it.

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

Hope there are no more GPT or any AI during future contests.

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

pls tell me i'm not the only one that used LCA to AC F.

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

Alternative solution for H:

Make a segment tree, and in each node, place the following things:

  • The length of the segment (call it $$$l$$$);

  • The number of subsequences with each start and end (call it $$$C_{i,j}$$$);

  • And the number of non-equal adjacent elements across all subsequences (call it $$$ans$$$).

We can find $$$ans$$$ in the following way: either the adjacent elements are both in the left, both in the right, or one's in the left and the other is on the right. So it's gonna be

$$$left_{ans} \cdot 2^{right_{len}} + right_{ans} \cdot 2^{left_{len}} + \sum_{0 \le i,j,k,l \le 1, j \neq k} left_{C_{i,j}} \cdot right_{C_{k,l}}$$$

.

This is what the code looks like: 305334877

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

Can someone please explain why two pointer does not work in Problem C2 after sorting array b?

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

could C1 also be solved using masks? 305285624 if yes, why doesn't this work ?

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

I liked problem D. never used prefix sums like that before. Very interesting contest overall :D (A little too much brainrot for me tho). Also I was curious if using DFS/BFS is a good idea in problem F. It might be redundant, but if anyone solved with bfs/dfs, please share your solution.

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

Can anyone tell me where this solution for problem G might be going wrong
I believe, I did it similar to the approach given in editorial

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

Can someone pls help with F problem. I have maintained a neighboring frequency map and just checking if frequency > 1 for some element.

https://codeforces.me/contest/2065/submission/305373353

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

2065D - Skibidus and Sigma Editorial

Sort each array in decreasing order. Sort the arrays themselves in terms of their sum, from largest sum to smallest Put together the final array Take the score This score is guaranteed to be maximal.

Bolded part is a mistake?

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

Problem G https://codeforces.me/contest/2065/submission/305402634 Can someone please tell me what i am doing wrong I am wrong answer on 4th case

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

Why my O(16 * n * logn) solution on H got tle :(

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

can somebody tell me at what test case my code might be failing 305361698

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

    PLZ Somebody help me with this

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

      Nevermind sorry, the advice I gave earlier is for C2.

      I looked through your code. I would try to make sure of two things:

      1. It seems like when you shift the one in front (d[i + 1] = 1), you then set the next one to always enter the first part of the for loop. In other words, in your code, I think once you flip one in front, it always flips the one in front regardless of whether or not it should. Always check, in your code, that every flip you do decreases or increases the number if it is expected to do that. It is a bit hard to tell what the d array is used for, it seems to be telling whether or not a bit is able to be flipped but is interacting with the ones in front, which haven't been checked yet?

      2. Make sure your code is not O(n^2) time complexity. I think your funci() and funi() functions are O(N), and if these run on every index, you might get a time limit problem because doing this on every index is O(n^2). I am not 100% sure of this.

      Sorry for the initial wrong example/

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

Question H's tutorial has faulty LaTeX in the "Solution" section near the bottom. In the last math's pseudocode, there's some oplus1 thing. I think it's just supposed to be s[j] XOR 1.

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

CAN ANYONE EXPLAIN WHY THIS APPROACH TO c WAS WRONG?

https://codeforces.me/contest/2065/submission/305299896

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

Does anyone tell me why my O(16 * n * logn) solution on H was TLE ? I read William Lin's solution and it may the same with mine

Here is my solution https://codeforces.me/contest/2065/submission/305249433

Here is William Lin's solution https://codeforces.me/contest/2065/submission/305272835

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

I started from the end in C2 problem, and maximize the element but less then its next element, but i get wrong answer.

can anyone tell why this approach is different from the given approach

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

ARE RATINGS UPDATED?

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

forgive

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

hi everyone ! Could anyone please help me? Got some troubles on C2, it falls on a 2nd test, but ~7000th token. Cant figure out what the problem is:( 305525156

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

My idea for H: Let $$$dp_0$$$ being the sum of all sequences ending at 0, $$$dp_1$$$ is defined the same way, $$$nums_0$$$ is the number of subsequences ending at 0 before position i, $$$nums_1$$$ defined the same way.

The brute force code looks like this:

               if (i)
               {
                   if (s[i - 1] - '0')
                       num1 += (1 << (i - 1));
                   else
                       num0 += (1 << (i - 1));
               }
               dp = {dp[0] + dp[1] + (num1 + 1) * (s[i] == '0'), dp[0] + dp[1] + (num0 + 1) * (s[i] == '1')};

So, how do we optimize this? Matrix multiplication is looking good here. Let's use matrix multiplication:

$$$\begin{pmatrix}dp_0 & dp_1 & nums_0 & nums_1 & 1\end{pmatrix}:=\begin{pmatrix}dp_0 & dp_1 & nums_0 & nums_1 & 1\end{pmatrix} \begin{pmatrix}1 & 1 & 0 & 0 & 0 \\ 1 & 1 & 0 & 0 & 0 \\ 0 & [s_i=1]&1&0&0\\ [s_i=0] & 0&0&1&0\\ [s_i=0]*(1+[s_{i-1}=1]*2^{i-1}) & [s_i=1]*(1+[s_{i-1}=0]*2^{i-1})&[s_{i-1}=0]*2^{i-1}&[s_{i-1}=1]*2^{i-1}&1\end{pmatrix}.$$$

The only thing left to do is to use a segment tree, which I implemented in 305304142.

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

    My solution use 3x3 matrix.

    Let $$$n_0,n_1,S$$$ are the number of subsequences ending at 0 before position i, the number of subsequences ending at 1 before position i, the sum of f() before position i.

    when s[i] = '0':

    $$$n_0\to 2n_0+n_1+1,n_1\to n_1,n_0\to 2S+n_1+1$$$

    symmetrically, when s[i] = '1',

    $$$n_0\to n_0,n_1\to 2n_1+n_0+1,n_1\to 2S+n_0+1$$$

    One nice insight is homogenization (is that word?)

    Let $$$n_0'=2n_0+1,n_1'=2n_1+1,S'=2S+1$$$

    We have $$$(n_0',n_1',S')\to(2n_0'+n_1',n_1,2S'+n_1)$$$

    $$$M_0=\begin{bmatrix} 2 & 0 & 0 \\ 1 & 1 & 1 \\ 0 & 0 & 2 \end{bmatrix}$$$

    matrix for '1'

    $$$M_1=\begin{bmatrix} 1 & 1 & 1 \\ 0 & 2 & 0 \\ 0 & 0 & 2 \end{bmatrix}$$$

    We have

    $$$2\text{ans}+1=[1,1,1]\times \prod\limits_{i=1}^nM_{s[i]}\times [0,0,1]^T$$$

    Code 320437455 takes about 500ms

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

Am I the only who is getting TLE in H after using segment trees effeciently(as far as i know) Can someone help me to optimize it ? 305573607

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

This was a great contest, which I thoroughly enjoyed virtualling with AG-88301, however I must say macaquedev's editorials are significantly lacking in their accuracy.

On line 1 of his editorial for D, he introduces a new term $$$c_2$$$, which appears from nowhere, and is clearly meant to be $$$b_3$$$...

In the editorial for E, he also says WLOG $$$n \gt m$$$ when the correct assumption to make is $$$n \ge m$$$, since you cannot assume they are not equal...

Can we have more proofreading of editorials as I find this frankly unacceptable that such simple mistakes were able to come through both macaquedev's editorals, and the seemingly non-rigourous proofreading by higher ups. I hope I will never see this kind of inaccuracy again.

User macaquedev is also reknowned for his use of the word "trivial", and I did not find it mentioned ONCE in this editorial set... This is frankly unacceptable behaviour and should be dealt with immediately!

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

Nice Div. 4 contest. As a virtual contestant, I think the thoughts of these problems are fluid. And the difficulty setting of the questions is smooth.

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

Can somebody explain me why my solution for problem 4 doesn't work correctly?

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int binSearch(vector<int>& arr, int itm1, int itm2)
{
    int l = 0, r = arr.size();
    while (l + 1 < r)
    {
        int m = l + (r - l) / 2;
        if (arr[m] - itm1 < itm2)
        {
            l = m;
        }
        else
        {
            r = m;
        }
    }
    if (r != arr.size() && arr[r] - itm1 > itm2)
    {
        return arr[r];
    }
    else
    {
        return -1;
    }
}

void solve()
{
    int n, m; cin >> n >> m;
    vector<int> arr1(n);
    vector<int> arr2(m);
    for (int i = 0; i < n; ++i) cin >> arr1[i];
    for (int i = 0; i < m; ++i) cin >> arr2[i];
    sort(arr2.begin(), arr2.end());
    arr1[0] = min(arr2[0] - arr1[0], arr1[0]);
    for (int i = 1; i < n; ++i)
    {
        int itm = binSearch(arr2, arr1[i], arr1[i - 1]);
        if (itm == -1)
        {
            if (arr1[i] < arr1[i - 1])
            {
                break;
            }
        }
        else
        {
            arr1[i] = min(itm - arr1[i], arr1[i]);
        }
    }
    cout << (is_sorted(arr1.begin(), arr1.end()) ? "YES\n" : "NO\n") << "\n";
}
int main()
{
    int t; cin >> t;
    while (t--)
    {
        solve();
    }
    
    return 0;
}

  • »
    »
    21 месяц назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    #include <iostream>
    #include <string>
    #include <algorithm>
    #include <map>
    #include <set>
    #include <vector>
    
    using namespace std;
    
    #define ll long long
    
    void solve()
    {
        
        int n; cin >> n;
        vector<int> a(n); for (int i = 0; i < n; i++){ cin >> a[i]; }
        
        sort(a.begin(), a.end());
    
        bool flag = false;
        for (int i = 1; i < (n - 2); i++){
            if ((a[i] == a[i + 1]) && ((a[i - 1] + a[i] + a[i + 1]) > a[i + 2])){
                cout << a[i - 1] << ' ' << a[i] << ' ' << a[i + 1] << ' ' << a[i + 2] << '\n';
                flag = true;
                break;
            }
        }
    
        if (!flag){
            int aa = a[0];
            int bb = a[1];
            if (aa == bb){
                for (int i = 2; i < (n - 1); i++){
                    if ((aa + bb + a[i]) > a[i + 1]){
                        cout << aa << ' ' << bb << ' ' << a[i] << ' ' << a[i + 1] << '\n';
                        flag = true;
                        break;
                    }
                }
            }
        }
        if (!flag){
            int aa = a[n - 2];
            int bb = a[n - 1];
            if (aa == bb){
                for (int i = 0; i < (n - 3); i++){
                    if ((aa + bb + a[i]) > a[i + 1]){
                        cout << aa << ' ' << bb << ' ' << a[i] << ' ' << a[i + 1] << '\n';
                        flag = true;
                        break;
                    }
                }
            }
        }
        if (!flag){
            vector<pair<int, int>> g(n - 1);
            for (int i = 0; i < (n - 1); i++){
                g[i].first = a[i + 1] - a[i];
                g[i].second = i;
            }
            sort(g.begin(), g.end());
            for (int i = 0; i < (n - 1); i++){
                if (a[i] == a[i + 1]){
                    for (int j = 0; j < (n - 1); j++){
                        int idx = g[j].second;
                        if (idx != (i - 1) && idx != i && idx != (i + 1)){
                            if ((a[i] + a[i + 1]) > g[j].first){
                                cout << a[i] << ' ' << a[i + 1] << ' ' << a[idx] << ' ' << a[idx + 1] << '\n';
                                flag = true;
                            }
                            break;
                        }
                    }
                    if (flag){
                        break;
                    }
                }
            }
    
    
    
        }
        if (!flag){
            cout << -1 << '\n';
        }
    
    
    
    
    
    
    
    
    
    
    
    }
        
    int main()
    {   
        ios::sync_with_stdio(false);
        cin.tie(nullptr); 
        cout.tie(nullptr);
        int t = 1;
        cin >> t;
        while (t--){
            solve();
        }
        return 0;
    }
    
    
»
21 месяц назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In 2065C, what if we apply a similar logic from the back (i.e. start from the last index, try to maximize it, then for index i, pick the greatest value of a[i] that is <= a[i+1], then proceed to i-1 and keep doing this repeatedly). Will this not work? If not, why?

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

In solution of problem H, fix the sumI[s[j]\oplus1] += 2^(j-1) line.

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

hack of this submission on problem C:

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

Here is my much simpler solution for F 346635848. simply check if any value repeats in d <= 2 for any vertex, then it is majority value