Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

_MCYYDS_'s blog

By _MCYYDS_, history, 5 weeks ago, In English

2250A - Threshold Movement

Solution
Code

2250B - String Construction

Hint 1
Solution
Code

2249A - Rank Subsequence

Hint 1
Hint 2
Solution
Code

2249B - Permutation Cuts

Hint 1
Hint 2
Hint 3
Solution
Code

2249C - Double-Rift Dial

Hint 1
Hint 2
Hint 3
Solution
Code

2249D - Xor Permutation Matrix

Hint 1
Hint 2
Hint 3
Solution
Code

2249E1 - String (Easy Version)

Hint 1
Hint 2
Hint 3
Solution
Code

2249E2 - String (Hard Version)

Hint 1
Hint 2
Hint 3
Solution
Code

2249F - Even Simple Path

Hint 1
Hint 2
Hint 3
Solution
Code
  • Vote: I like it
  • -410
  • Vote: I do not like it

»
5 weeks ago, hide # |
Rev. 2  
Vote: I like it +49 Vote: I do not like it

Bruh they need to make the contest pre-review phase more thorough now that the oldest trick in the book (literally as old as the Fibonacci Heap) slipped into a rated Div.1

»
5 weeks ago, hide # |
 
Vote: I like it +75 Vote: I do not like it

Is it just me or does div1F editorial look AI generated

  • »
    »
    5 weeks ago, hide # ^ |
     
    Vote: I like it +15 Vote: I do not like it

    yeah the whole "Why A", "Why B", "Why C" subheadings instead of a flow of logic or motivation for ideas is a little sus

    • »
      »
      »
      5 weeks ago, hide # ^ |
      Rev. 2  
      Vote: I like it +3 Vote: I do not like it

      bro edited the D1F edi to replace "Why X" with "Proof i: X". I think D1F being on the internet and the things said about the problems mid-contest could be honest mistakes but this is kinda shameless.

  • »
    »
    5 weeks ago, hide # ^ |
     
    Vote: I like it +10 Vote: I do not like it

    This does look very AI-ish. I have never seen an editorial like this. Maybe the author didn't have any idea for this problem and simply found a hard enough algorithm and asked AI to write a solution.

    • »
      »
      »
      5 weeks ago, hide # ^ |
       
      Vote: I like it +52 Vote: I do not like it

      :skull: the more I see the more cynical I become

      • Ban evading and "I don't have to follow the rules"
      • Evidence that F was made in a hurry with AI-generated editorial and googling gives a solution
      • Leaking during round
  • »
    »
    5 weeks ago, hide # ^ |
     
    Vote: I like it +24 Vote: I do not like it

    It looks like it was generated by ChatGPT.

    I mean, the authors can use AI to write editoral, for sure, but they should polish it to make it easier to read at least.

»
5 weeks ago, hide # |
 
Vote: I like it +54 Vote: I do not like it

Bad contest, bad problems order.

»
5 weeks ago, hide # |
Rev. 2  
Vote: I like it +92 Vote: I do not like it

In the solution of problem "2249B — Permutation Cuts" you have misspelled '!pre[cut]' by writing '!pre' only..

Edit : Author's solution also gets TLE on test 20 .

»
5 weeks ago, hide # |
 
Vote: I like it -20 Vote: I do not like it

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

»
5 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I dont know but i found this contest on the harder side. idk 1 question took me around 1hr although i always used to solve div 2 A and b with in 25 to 30 min, but this one was little diffrent

»
5 weeks ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

I have a linear approach for Div.1C, but I can't prove it. https://codeforces.com/contest/2249/submission/384417010

  • »
    »
    5 weeks ago, hide # ^ |
     
    Vote: I like it +5 Vote: I do not like it

    My approach is also O(n): https://codeforces.com/contest/2249/submission/384423262

    The idea I came up with is that if 1 and N are taken, the set of indicies not taken should form a single contigious block.

    Thus, consider each "half" from 1 to N or N to 1. I think we can show that the only candidate positions are a run of concecutive increasing/decreasing numbers from the start and at most one other position later. We can brute force the positions, except for the run; However, for the run of posiitons, the positions in the middle of the run will have the same result, so we can check one of them to check for all of them.

»
5 weeks ago, hide # |
 
Vote: I like it -16 Vote: I do not like it

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

»
5 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

my first contest!! (i messed up so bad lol)

»
5 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Why does everyone think this round's horrible?

»
5 weeks ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

I used the sample code for problem 2249B - Разрезание перестановки from this blog to run the following test case:

1
4
2 3 1

The program outputs 3, but the correct answer should be 2.

»
5 weeks ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

I made a short solution for Permutation cuts which i feel uses much simpler idea than editorial Submission id : 384584689 ~~~~~~~~~~

include<bits/stdc++.h>

define ll long long

define db double

using namespace std;

bool isok(vector& a) {

int n = a.size(), i=0;
vector<ll> seen(n+2);
while (i + 1 < n && a[i] <= a[i + 1]){
    seen[a[i]] = 1;
    i++;
}
while (i + 1 < n && a[i] >= a[i + 1]){
    i++;
    if(seen[a[i]]) return false;
}
return i == n &mdash; 1;

} void solve(){

ll n;
cin>>n;
vector<ll> a(n-1);
for(ll i=0; i<n-1; i++) cin>>a[i];
//condition of ans = 0 --> should be mountain and right and left side should contain distinct values and no element = n
ll ans= isok(a);
sort(a.begin(), a.end());
if(a[n-2] == n) ans=0;
for(ll i=1; i<n-1; i++){
    if(a[i]==a[i-1]) ans = (ans*(a[i] &mdash; i))%998244353;
}
cout<<(2*ans)%998244353<<'\n';

}

int main(){

ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);

int t=1;
cin>>t;
while(t--) solve();

} ~~~~~~~~~~

  • »
    »
    5 weeks ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I can see many solutions being submitted to this problem that uses this short solution, but I cant seem to find any intuition behind this approach, any help would be appreciated.

    • »
      »
      »
      5 weeks ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      a should be mountain and max(a) < n, then only valid permutation can be formed. Conditions: a can be divided in consecutive block of same elements, and an element belong to one block only. Like 3,4,4,5,5,4 is not possible, blocks => [[3],[4,4],[5,5],[4]] here 4 belong to two blocks. First occurrence of element fix the position of a[i] while repeated occurrence contribute to val=a[i]-i value Since we are arranging elements we will multiply val. Why res*2? Cause we can swap position of n and n-1 in final permutation. Suppose: a => [1 2 3 4] two permutation exist [1 2 3 4 5] and [1 2 3 5 4]

      Correct me if I am wrong...

      • »
        »
        »
        »
        5 weeks ago, hide # ^ |
        Rev. 5  
        Vote: I like it 0 Vote: I do not like it

        Hey I just wanted to ask some doubts regarding the above code...

        So in the editorial they say we have to find the points c such that a[c] != a[c+1], until a[c] array is non decreasing and after that it's non increasing. For each such point we are told to merge the array and repeat the process.

        But here in the above code author forgoes calculating all the valid c points and directly goes to sorting the array and than calculating the number of permuntations. So does this imply that there is only one place where this condition is valid. If not how does the code take in account for different c values. Like for example:

        7
        3 5 6 6 4 1

        So like here there are two valid c's, one before the first 6 and one after the last 6.So how does the code take in account these cases and manages to count the number of permuntation in single pass???

        edit: Nevermind they both produce the same permuntations because the merged permuntation is the same

        edit2: Hey I understood why the multiply by two things work. The problem of trying to find the valid place of c can be seen as fixing two mountains. So really whatever place you get n to be won't change the number of permuntations because suppose you place n somewhere than there would be n-1 and it would also be somewhere.

        Now it could be to the left or right doesn't matter. We just have to check the number of permuntations we can make in this valley between n and n-1 and similarly before n and after n-1 or whatever there places may be accordingly.

        You would only consider this valley because valleys made by any other elments ruins the structure because it would not include n or n-1 and these two would produce other peaks which would invalidate either of the non increasing or decreasing condition. So that's why other peaks formed with n would not produce any valid permuntations.

        So thus we simply sort the array to get the prefix max array and and than simply find the array with given prefix max. Now in this array we can swap n and n-1 and so we multiply the answer by 2.

»
5 weeks ago, hide # |
Rev. 2  
Vote: I like it +1 Vote: I do not like it

I took 1h to solve C but 6h to solve D. I never had intution or expectation that some elements could be fixed. I was trying dp to count every possiblity. Took so long to realize this. A glimpse of my suffering on D. I first realized a could increase then decrease. Then realized n must lie in max area of a. Hopefull now you may imagine what went on me. submission

I also wasted 30m on C by just thinking of DP optimisation, then realized for a fixed n right constrains will either stay statisfied or violated immediately and taking an element can only violate left constrain of at most one future element hence we don't need to explore all possiblity.

Any suggestion how to solve these ad-hoc problems during contests?

»
5 weeks ago, hide # |
Rev. 3  
Vote: I like it -24 Vote: I do not like it

.

»
5 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

A solution for Div2- D, Similar approach but easier to understand with 2 pointers. https://codeforces.com/contest/2250/submission/384741002

»
5 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

if k>n then"The map y↦y⊕x partitions S into n/2pairs"is wrong

  • »
    »
    5 weeks ago, hide # ^ |
     
    Vote: I like it -16 Vote: I do not like it

    Here we already assume $$$n$$$ is a power of two and $$$0 \lt x \lt n$$$. Thus $$$y\oplus x\in S$$$ for every $$$y\in S$$$, and since $$$x \gt 0$$$, the involution $$$y\mapsto y\oplus x$$$ has no fixed points. Therefore, it indeed partitions $$$S$$$ into $$$n/2$$$ pairs.

»
5 weeks ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

editorial downvoted to hell => author has lower contrib than CarViz

»
4 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

An approach to D (the editoral personally felt overcomplicated) 385050727 The idea is that whenever the sequence of n-1 occurs (which must occur) , n and n-1 must be placed at either end of it i.e if the n=6 and a=[2,4,5,5,3] then in the final res array n and n-1 must occur at index 2 and 4 or vice versa.

From there, we go in decreasing order of numbers and see valid positions a number can be placed if it is present in array a then place it at that index in res else it will be placed in valid gaps(review code for the idea)

Beyond tha,the cases for 0 are: i)If n occurs or n-1 doesn't ii)If the array contains duplicates at non-consecutive locations iii)If the given array doesn't form a plateau i.e non-decreasing then non-increasing

»
3 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I submit the Author's solution on 2249B wrong on sample!!!tell me why!!Is there somebody fix it?