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

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

Hello, Codeforces!

I am very excited to invite you to my second-ever contest, Codeforces Round 1065 (Div. 3), which will start on 20.11.2025 17:35 (Московское время)! In this contest, you will be given 2 hours and 30 minutes to solve 7 problems, two of which have been split into subtasks. The subtasks for a given problem are not necessarily placed adjacently in the problemset.

The round will be hosted by the rules of educational rounds (extended ICPC). Thus, all solutions will be judged on preliminary tests during the round, and after the round, there will be a 12-hour phase of open hacks. After the open hack phase, all accepted solutions will be rejudged on successful hacks. Also, note that there is no score distribution — rank will be determined by number of problems solved, followed by penalty; wrong submissions will incur the usual penalty of 10 minutes, following the rules of educational rounds.

As a reminder, only trusted participants of the third division will be included in the official standings table. This is a compulsory measure for combating unsporting behavior. To qualify as a trusted participant of the third division, you must:

  • take part in (and solve at least one problem in) at least five rated rounds
  • and not have had a rating of 1900 or higher at any moment in time.

Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you (unless you register unrated).

Also, note the rule restricting the use of AI. If you are caught breaking this rule, you will be condemned to life spent in prison the basement of some unspecified Codeforces user. Said person's basement is a rather unenjoyable place to live in, so I would advise adhering to the rules.

I would like to thank the following people for helping make this round possible!

Good luck, and have fun!

UPDATE: Due to issues with Cloudflare, the round has been rescheduled for 20.11.2025 17:35 (Московское время).

UPDATE: Editorial

  • Проголосовать: нравится
  • +389
  • Проголосовать: не нравится

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

As a tester, yuri is peak

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

a @reirugan round ? i wish it will be as good as your previous div3 round !!

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

anime kiss jumpscare

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

what's today's codeforces topic?

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

Could you please remove the gif?

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

codeforces when my mom enters the room

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

as a tester, this gif actually spoils the entire contest

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

I got jumpscared so hard by that gif.

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

'condemned to life spent in the basement of some unspecified Codeforces user' when are we specifying this lad

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

As a tester, unspecified Codeforces user is yuri

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

As a tester, reirugan tested my yuri knowledge.

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

What is the anime name so I can watch it with my family later?

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

Tester here — had fun with this round! Cool problems (gif got changed)

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

source? for cf practice ofc

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

we got gay codeforces before GTA VI?

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

can't wait for the contest's problem statements

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

is this a hint that there will be at most 18 problems?

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

opening codeforces is never disappointing

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

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

As a participant always love to taking part in Div. 3 contests

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

All my favorite NYU students have helped in this contest. Wow!

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

The picture is beautiful, feeling happy when opening codeforces.

Btw, who is the charactor in the picture?

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

As a reirugan fan good luck guys

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

安達としまむら round!

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

skibidi

Related ? $$$67$$$

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

Adachi Sakura!!!

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

How lucky I am to see a Yuri picture on CodeForces! It really makes me curious.

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

"macaquedev for pretending to test;" lol

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

The subtasks for a given problem are not necessarily placed adjacently in the problemset.

Uhh what do you mean by that??

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

Can I try? I'm just a new person

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

Llegar, partir y merendar

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

Hope to solve at least 5 problems,thus increase my rating.:)

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

Today is my birthday:)

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

how can i participate as a tester in a competition?

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

hope everybody get a positive Delta

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

Looking for a "Demon Slayer" based contest if we are entering the zone of anime in cf!

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

Thank you cloudflare for forcing this round to be delayed

I blame the vibecoder that broke cloudflare's code

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

was the contest originally now and they postponed it or am I tripping

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

What just even happened XD

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

what is wrong with cloudflare :》

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

I was looking forward to the yuri. At least it didn't happen during the actual round.

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

Why is the contest delayed?

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

hello?

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

Wtf???Rescheduled , was looking forward for the contest.

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

Actually it went well just before the contest begin...lol

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

I hate Cloudflare:(

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

just wanted to solve some Div3 for me

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

It's amazing that Cloudflare is fixed a minute before the original contest start time.

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

I'm seeing that Shayan's and Arpa's streams are scheduled to release within the next three hours. Please get rid of them!

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

    Arpa's video has already been delayed

    I believe Shayan hasn't prerecorded his video; my understanding is that he usually screenrecords live during the contest

    Thanks for pointing it out, though!

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

Why the contest has delayed but the stream has not delayed?

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

Why 48 hours delay :(

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

So, Cloudflare has always been the villain?

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

cloudflare disappointed us all

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

thanks i have my exams tomorrow. 2.5 hrs saved. I'll utilise this in sleeping

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

W organizers!!! I thought I would miss todays round (╥﹏╥)

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

I hate Cloudflare...

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

Dead internet theory has a new definition now

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

Non-hackers getting a crawling ban is sweet justice given all the pain hackers have experienced over the past year.

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

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

Adashima is the best!

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

C2 > DEFG

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

Div. 3>>1

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

For problem E,my code 349964120 construct a permutation with atmost 1 bad index.I wonder whether 6 was there just to confuse.

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

My B solution kept failing on some hidden case, I am confident my logic is correct. Also for D, I was trying to use DSU based approach but kept timing out. Any ideas on approach for problem D?

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

In Problem E, why multiples of 2, 5 and 10 doesn't work but multiples of 2, 3 and 6 work ?? Is it because we can have at most 6 bad indices and not 10 indices ?

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

    we can make 0 bads as well , the fact that matters is that for any N there are total primes always <=N/2 with N :)

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

    a proof for why 2,3 specifically work:

    consider a solution of the form

    **_**_**_...

    where the * themselves form a sequence s.t. the adjacent * are not coprime. clearly, such a solution has no bad indices. so, it suffices to find a sequence of the * numbers with length >= 2n/3.

    consider multiples 2 and 3. it now suffices to show that these cover 2/3rds of 1 .. n. consider partitioning 1 .. n into disjoint groups of 3 starting from 3. let j be the first number in the block (e.g. 3,6,9,etc.). if j%2==0, then j%2==0 and (j+2)%2==0. so we have covered 2/3 numbers in the range j,j+1,j+2. if j%2!=0, then j%3==0 and (j+1)%2==0. so we have also covered 2/3 numbers in this range. so, from any n we can form a valid sequence * using multiples of 2 and 3, but making sure we carefully place 6 to connect the 2 and 3 multiples. so we use 2 4 8 .. 6 3 9 15 .. for the *'s and fill in the rest.

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

felt like this was hard compared to other div3

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

I was able to do G in $$$O(N * log(N) ^ 2)$$$
Code link: https://codeforces.me/contest/2171/submission/349941964

Is there a better solution?

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

That was an awesome contest for me! After giving so much effort, i solved the c problem

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

I solved A, C1 and C2 but not B wtf?

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

Is this div2?

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

Felt difficult than almost all the div3 I participated in till now ...

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

F is much easier than E, and is too close to D, separating them by E was just evil.

Also, I skipped the first sentence of each problem since it add nothing to the statement, this also caused me to not notice that it has two versions...

»
12 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
void sol(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>p[i];
        a[p[i]]=i;
    }
    if(a[1]<a[n]){
        cout<<"Yes\n";
        return;
    }
    int mx=1,mn=n; 
    for(int i=a[1];i<=n;i++) mx=max(mx,p[i]);
    for(int i=1;i<a[n];i++) mn=min(mn,p[i]);
    cout<<(mn<mx?"Yes\n":"No\n");
}

I got an WA on pD but I don't know why. Can anyone help me? thx

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

I personally not satisfied by today's div3 :( Maybe I will get downvotes. I just shared my sadness

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

How tf is this a wrong edge list !?

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

I'm so happy to reach such a high place in this round! The thrill just won't go away!

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

C1 & C2 are nice problems! I was looking at C2 and had absolutely no idea how to do it but after a quick peek at C1 I had an observation that got me through C2!

Had it not been for C1 i would have been stuck at C.

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

Why would you want to make the mod 1e6 + 3 on G?

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

    Do you have a solution that does not require precomputing factorials?

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

      I missed this. You're right. Thanks for explanation :)

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

      If all the constraints are kept the same except for the mod (most importantly, $$$1 \leq a_i \leq b_i \leq 10^6$$$ is kept) and we only considered $$$t = 1$$$, I'm aware of a (partial) solution with two steps than can be done in $$$O(n)$$$ for the first step and $$$\tilde{O}(sqrt(mod))$$$ for the second step (per test case). This idea still requires precomputation, but only for factorials up to $$$b_i - a_i$$$, so we need an additional $$$O(max(b_i))$$$ precomputation. With $$$t = 1$$$, this idea can support mods around $$$10^9$$$, however it 1) cannot be used to solve G for significantly larger $$$t$$$ (I suspect $$$t = 10$$$ already causes TLE) and 2) is definitely not suitable for Div 3, for reasons I will explain later.

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

Can someone please tell me why my dsu code for D is giving WA? Submission:349981598

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

    Consider the case 3 5 2 1 4

    Your answer is NO, but the correct answer is YES.

    Step 1, the code performs union(5, 3).

    Step 2, the code only performs union(4, 1) and union(4, 3).

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

I gave this contest after registration properly. And it was my first contest. Then why it is appearing in unrated section and not in rated section for me? Help pls

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

I introduce a solution of problem E,but I can't prove it(maybe I just know a little) Firstly, make a number of (n/2)+1 called Rt , and continue ues it ,if it's a prime number,put in the first.And then,from 2 to n,make the number mutiples,every time chose two number,such as (prime number, a,b(a and b have mutiples relation)),continue to put such numbers,until Rt > n ,put other number using mutiples relation, ans you will pass the problem.

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

i was registered as unrated by mistake in Codeforces Round 1065 (Div. 3) .please check my submissions my name is Manisha0369

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

Can anyone tell / give any hints IN C problem in genral?

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

    try playing the game starting from the index 1 , think like u are the player playing the game and what optimal moves(swap) u need to play in order to :

    1. maximise(greater than ur opponent) ur score , meanwhile
    2. the swap operation must not increase ur opponents score so that ur opponent's score became greater than ur current score .

    or in more simple words , at the ith move , u can either choose to swap or not to swap. swap only if the operation increase ur score than current or it decreases ur opponents score.

    // here the easy version assumes only 0s and 1s hence the solution is a lil bit different , the above explained algo fits best with the hard version

    // C1 — easy

    /*
    code by - Aryan Shrivastav
    */
    
    /*
    observations : 
    
    */ 
    
    #include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define vi vector<int>
    #define vll vector<long long>
    #define co_endl cout<<'\n'
    #define f(i,a,n) for(int i=a ; i<n ; i++)
    
    void SOLVE(){
    
        int n;
        cin>>n;
    
        vi a(n);
        vi b(n);
    
        string ans;
    
        int total_a = 0;
        int total_b = 0;
    
        f(i,0,n){
            cin>>a[i];
            total_a+=a[i];
        }
    
        f(i,0,n){
            cin>>b[i];
            total_b+=b[i];
        }
    
        f(i,0,n){
            if(i%2 == 0){ // ajisai turn
                if(total_a%2 == 0){ // total_a is even 
                    if(a[i]==0 && b[i]==1){ // swap
                        a[i] = 1;
                        b[i] = 0;
                        total_a++;
                        total_b--;
                    }
                    else if(a[i]==1 && b[i]==0){
                        a[i] = 0;
                        b[i] = 1;
                        total_a--;
                        total_b++;
                    }
                }
                else{ // total_a is odd // dont swap
                }
            }
            else{ // mai turn
                if(total_b%2 == 0){ // total_b is even 
                    if(a[i]==1 && b[i]==0){ // swap
                        a[i] = 0;
                        b[i] = 1;
                        total_a--;
                        total_b++;
                    }
                    else if(a[i]==0 && b[i]==1){
                        a[i] = 1;
                        b[i] = 0;
                        total_a++;
                        total_b--;
                    }
                }
                else{
                    // dont swap
                }
            }
        }
    
        int ans_a = total_a%2;
        int ans_b = total_b%2;
    
        if(ans_a > ans_b){
            ans = "Ajisai";
        }
        else if(ans_a < ans_b){
            ans = "Mai";
        }
        else{
            ans = "Tie";
        }
    
        cout<<ans;
    
        co_endl;
    
    }
    
    int main(){
    
        int t;
        cin>>t;
        while(t-->0){
    
            SOLVE();
    
        }
    
        return 0;
    }
    
    

    // C2 — hard


    /* code by - Aryan Shrivastav */ /* observations : */ #include<bits/stdc++.h> using namespace std; #define ll long long #define vi vector<int> #define vll vector<long long> #define co_endl cout<<'\n' #define f(i,a,n) for(int i=a ; i<n ; i++) void SOLVE(){ int n; cin>>n; vi a(n); vi b(n); string ans; int total_a = 0; int total_b = 0; f(i,0,n){ cin>>a[i]; total_a^=a[i]; } f(i,0,n){ cin>>b[i]; total_b^=b[i]; } f(i,0,n){ if(i%2 == 0){ // ajisai turn if( (total_a ^ a[i] ^ b[i]) > (total_b ^ b[i] ^ a[i]) ){ total_a = (total_a ^ a[i] ^ b[i]); total_b = (total_b ^ b[i] ^ a[i]); // swap int temp = a[i]; a[i] = b[i]; b[i] = temp; } } else{ // mai turn if( (total_a ^ a[i] ^ b[i]) < (total_b ^ b[i] ^ a[i]) ){ total_a = (total_a ^ a[i] ^ b[i]); total_b = (total_b ^ b[i] ^ a[i]); // swap int temp = a[i]; a[i] = b[i]; b[i] = temp; } } } int ans_a = total_a; int ans_b = total_b; if(ans_a > ans_b){ ans = "Ajisai"; } else if(ans_a < ans_b){ ans = "Mai"; } else{ ans = "Tie"; } cout<<ans; co_endl; } int main(){ int t; cin>>t; while(t-->0){ SOLVE(); } return 0; }

    do reply me if u got the approach and consider upvoting it :)

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

i guess $$$O(m \sqrt m)$$$ memory gets passed in problem H (you just need to use 16 bit integers) 349971224

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

My rating is 1177 and had never got higher than now. I have solved at least one problem in at least five rated rounds, such as 1858, 1879, 1878, 2166, 2169. And I had never cheated in any round. But I wonder why it shows "Unrated allowed"?

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

Hello

Can anyone please help me to find cases in which mine code will fail (Give Tle) for problem — F It is giving tle on test case — 12 Thanks for helping

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
const int mod = 1e9 + 7;
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define deb(x...)
#endif
void solve();
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

bool check(vector<int> &a, int n)
{
    int mex = 1;
    set<int> st;

    for (int i = n; i >= 2; i--)
    {
        int ele = n - i + 1;

        st.insert(a[i]);

        while (st.find(mex) != st.end())
        {
            mex += 1;
        }

        if (mex == ele + 1)
        {
            return 1;
        }
    }

    return 0;
}

void solve()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);

    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }

    if (check(a, n))
    {
        cout << "No" << endl;
        return;
    }

    set<int> st;
    vector<vector<int>> ans;

    for (int i = n; i >= 1; i--)
    {
        auto id = lower_bound(st.begin(), st.end(), a[i]);
        vector<int> rm;
        for (auto it = id; it != st.end(); it++)
        {
            ans.push_back({a[i], *it});
            rm.push_back(*it);
            if (ans.size() == n - 1)
                break;
        }

        if (ans.size() == n - 1)
            break;

        int size = rm.size() - 1;
        for (int j = 0; j < size; j++)
        {
            st.erase(rm[j]);
        }

        if (rm.size() == 0)
            st.insert(a[i]);
    }

    cout << "Yes" << endl;
    for (auto val : ans)
    {
        for (auto node : val)
        {
            cout << node << " ";
        }
        cout << endl;
    }
}
»
12 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

i cant write a comment here

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

    I have a very easy solution to c1 and c2, you just have to change the checking condition in the c2 version. Now it says that the play should be optimal, that means if it's the first player's turn and he is ahead in score , then he won't swap. Likewise , if he is down by one then on his turn if on swapping his score increases then only he will swap otherwise not. Second player would do the same. Therefore,the solution might be a very simple greedy approach where on the i'th turn, each player checks the score and then swaps.

    Now C1 SOLUTION----->

    [submission:349984404]
    

    The snippet shows that first we calculate the original xor of all elements,then on each move swap them. If the score increases like it can be 1 or 0 only. Then on swapping the score of both of them will become their negation.

    C2 SOLUTION -------->

    [submission:349987068]
    

    In the C2 problem, the score now won't remain 0 or 1, but the logic remains the same, first calculate the default xor of all numbers then the greedy approach to check on each move whether the scores will change or not. We just update the scores in different way in C2 because in C1 only 0 or 1 were possible pair of total xor scores. Thank You, Niksy

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

very ezzz round for div.3

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

Tbh when i see a div 3 i smile it's easy and so amazing to pass , Hope they will be more div 3's by the time and also Good luck To everyone on this kind of contests or else !

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

That animation is so cool. I just love it