Блог пользователя eugenechka.boyko.2_0-0

Автор eugenechka.boyko.2_0-0, 17 месяцев назад, По-русски

こんにちは, Codeforces!

Со времени нашего первого раунда мы многому научились, и поэтому рады пригласить вас принять участие в Codeforces Round 1022 (Div. 2), который пройдет в 01.05.2025 17:35 (Московское время). Раунд будет состоять из 6 OR 7 задач на реализацию с Leetcode, где OR означает операцию побитового «мы не знаем», и 2 часа на их решение. Некоторые из задач раунда могут быть интерактивными, с их более подробным описанием можно ознакомиться здесь.

Раунд будет рейтинговым для всех участников с рейтингом ниже 2100, однако все участники с более высоким рейтингом могут принять участие вне конкурса.

Раунд полностью основан на задачах Липецкой командной олимпиады школьников (ЛКОШП), прошедшей недавно в, внезапно, Липецке, поэтому мы настоятельно просим всех участников олимпиады воздержаться от написания раунда.

Все задачи были придуманы и подготовлены m3tr0, suprend и мной.

Мы хотим сказать огромное спасибо Akulyat за фантастическую координацию раунда и игру в $$$\text{Tower Defense}$$$, а также каждому нашему тестеру:

И, конечно же, хотим поблагодарить MikeMirzayanov за すばらしい платформы Codeforces и Polygon, а также You за участие в раунде!

ДРОП1: Скоре дистрибутион: $$$500-1250-1500-2250-2750-3250$$$

ДРОП2: Поздравляем всех борцов с деревьями и башнями! Финальный мышинг:

Все участники:

  1. peti1234
  2. BurnedChicken
  3. potato167
  4. propane
  5. jiangly

Только рейтинговые:

  1. 2018LZY
  2. ft2007
  3. pzjQWQ
  4. cooluo
  5. under1oop

ДРОП3: Разбор на базе.

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

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

Isn't this quite late for the announcement to come out

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

what's the score distribution?

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

i have engineering graphic exam the next day of this round but i am from a warrior race

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

As a spectator excited to see how many of our talented newbies AK the contest

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

    As we know, many newbies are talented in using LLMs.

    It is well known that many newbies are talented in the use of LLMs.(As a steady newbie, it's clear that I'm not one of them)

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

image

hope to become CM

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

The subarashi in Japanese takes you to a random subarashi video. crazy man

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

May the force be with you to rock on..

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

All the best everybody :)

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

what about scores?

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

Как сделать в блоге "You", как в этом анонсе, чтобы по нему можно было перейти на профиль пользователя?

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

As a participant, I hope to solve two or three problems in this contest.

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

I hope it is not a speed round.

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

Hope to be Pupil!

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

Hoping for colour change delta

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

6 OR 7 problems, where OR means the bitwise "we don't know" operation

Should I be scared?

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

I'll get orange now

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

Subarashiiiiii!!!! (¬‿¬)(¬‿¬)(¬‿¬)

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

Happy May Day!

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

The OR in the announcement is the bitwise AND operation

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

As a participant, there will be a lot of blogs about cheaters right after the contest.

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

hoping for the first time in top 4k in div2 !

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

Scores? A: 500 B: 1250 -_- Used to seeing A 750 and B 1k guess now that’s the new norm.

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

Scores? A: 500 B: 1250 -_- Used to seeing A 750 and B 1k guess now that’s the new norm.

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

Cherry_blossom_ this person used ai in the last educational round and most probably is using ai now

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

Why did I get -300 for resending the task instead of -50?(b problem)

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

hhh, I have used too many time on problem B. It is a good problem!

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

me reading problem A .. is this div1 A

me reading problem B .. is this div1 B

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

I had 30+ seconds remaining, yet the submit button was not clicking. Too bad codeforces.

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

When is editorial coming out

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

What's up with these shitty difficulty distributions lately? D is way too hard for its position.

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

Hi, may someone please explain me D or give me a hint on why I might get TLE?

My submission is: 318015724

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

At first sight: C<D

In fact: C<<<<<<D

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

Your explaining pictures are excellent! I like it very much! How did you make it?

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

B,C=C,B

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

for the question 2 :

how the answer is 8 or 5 0 can someone elaborate ??

because for length 5 the minimum sum can be 4 1 1 1 1 0

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

Can anyone please tell me what was wrong with my code for problem C? It was failing again and again for pretests 2. Any help would be beneficial.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class ProblemC {
    public static class FastReader {
        private BufferedReader buffer;
        private StringTokenizer tokenizer;

        public FastReader() {
            this.buffer = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(buffer.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
    }

    public static void main(String[] args) {
        FastReader fast = new FastReader();
        final StringBuilder output = new StringBuilder();
        int t = fast.nextInt();
        while(t-- > 0) {
            final int n = fast.nextInt();
            long nums[] = new long[n];
            for(int i = 0; i < n; i++)
                nums[i] = fast.nextLong();
            output.append(solve(n, nums)).append("\n");
        }
        System.out.print(output);
    }

    public static int solve(final int n, long nums[]) {
        Map<Long, List<Integer>> indexMap = new HashMap<>();
        boolean marked[] = new boolean[n];
        for(int i = 0; i < n; i++) {        // Creating a map to store the indices of similar elements
            if(!indexMap.containsKey(nums[i]))
                indexMap.put(nums[i], new ArrayList<>());
            indexMap.get(nums[i]).add(i);
        }
        Arrays.sort(nums);      // Sort the weights array
        int index = n-1, count = 0;     // Start from descending order
        while(index >= 0) {
            for(int marker : indexMap.get(nums[index])) {
                // For each index of the same value
                if(!isMarked(marked, marker, n))     // check whether it can be marked
                    count++;            // If it cannot be marked create a clone there and mark it
                marked[marker] = true;
            }
            index -= indexMap.get(nums[index]).size();      // Subtract the group size to get to the next group
        }
        return count;
    }

    public static boolean isMarked(boolean marked[], int index, int n) {
        if(index > 0 && marked[index-1])        // Left check
            return true;
        else if(index < n-1 && marked[index+1])     // Right check
            return true;
        return false;       // If both check fails then it cannot be marked currently
    }
}
»
17 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Worst round I have joined yet

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

personally, I felt like the difficulty order was A > B > C.

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

    A: 1 + (maximum possible sum) /2 ... However, I don't have a formal proof for this.

    B: lots of casework and handling them gracefully

    C: simple observation => calculate total no of local maxima

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

casework in B makes it much tougher compared to C, C is just simple observation and sets

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

What is the question of B, inexplicable!!!!

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

am i dumb or was c more doable than b?

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

Did the authors mistakenly perform B^=C, C^=B, B^=C?

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

Can anyone please help me with this code for problem C. It passed the first pretest but was failing again and again in second pretest. Any help would be appreciated.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class ProblemC {
    public static class FastReader {
        private BufferedReader buffer;
        private StringTokenizer tokenizer;

        public FastReader() {
            this.buffer = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(buffer.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
    }

    public static void main(String[] args) {
        FastReader fast = new FastReader();
        final StringBuilder output = new StringBuilder();
        int t = fast.nextInt();
        while(t-- > 0) {
            final int n = fast.nextInt();
            long nums[] = new long[n];
            for(int i = 0; i < n; i++)
                nums[i] = fast.nextLong();
            output.append(solve(n, nums)).append("\n");
        }
        System.out.print(output);
    }

    public static int solve(final int n, long nums[]) {
        Map<Long, List<Integer>> indexMap = new HashMap<>();
        boolean marked[] = new boolean[n];
        for(int i = 0; i < n; i++) {        // Creating a map to store the indices of similar elements
            if(!indexMap.containsKey(nums[i]))
                indexMap.put(nums[i], new ArrayList<>());
            indexMap.get(nums[i]).add(i);
        }
        Arrays.sort(nums);      // Sort the weights array
        int index = n-1, count = 0;     // Start from descending order
        while(index >= 0) {
            for(int marker : indexMap.get(nums[index])) {
                // For each index of the same value
                if(!isMarked(marked, marker, n))     // check whether it can be marked
                    count++;            // If it cannot be marked create a clone there and mark it
                marked[marker] = true;
            }
            index -= indexMap.get(nums[index]).size();      // Subtract the group size to get to the next group
        }
        return count;
    }

    public static boolean isMarked(boolean marked[], int index, int n) {
        if(index > 0 && marked[index-1])        // Left check
            return true;
        else if(index < n-1 && marked[index+1])     // Right check
            return true;
        return false;       // If both check fails then it cannot be marked currently
    }
}
»
17 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

how to solve D, E ?

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

D seems like binary search problem. I may be wrong.

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

The gap between C and D is too big!

I spend on A,B,C for only 30 min, but it took an hour and a half on solving D, and there was still no gain from D.

Is this a penalty sitting?

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

took too long to realize A. and got cooked on B.

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

I hope the System tests accounts for O(n) sols in D.

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

In problem D, does there exist a test case that we can find the lengths of arrays A and B in more than 250 queries?

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

Where is the editorial?

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

why not swap pB & pC, and it's the worst pB I experienced.

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

In my humble opinion, B was really not fun. I couldn't find a better approach than to enumerate edge cases, which isn't much interesting imo.

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

who spent time actually figuring out problem A.. I just guessed it will always be even :( very sad.

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

Edit: Nvm I outputted x+1 instead of x.

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

Overall Good contest I enjoyed A, B and C.

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

How to solve B? C was easier than B imo.

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

    It's too many conditions and too many if-elses.Need to carefully think of what if n is 1,2,other;and what if x is 0,1,other.

    Here's my code.https://codeforces.me/contest/2108/submission/317970208

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

    B was just greedy.. look at the binary representation of x and notice that all the set bits of X other than the 0th bit should come only once in answer if we want to minimize the sum and rest all numbers can be one.. Of course there is an edge case which was mentioned in sample cases as well 317990225 you can understand it from here.. For some reason i messed up C , i feel dumb right now, could have been a great contest for me but nonetheless will see next time.. Can you tell your approach for Problem C?

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

I know I failed in solving problem E, but knowing the solution of this seems to be a big help.

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

casework problem like B, can hell your whole contest xD

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

this round was harder than usual

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

As a participant I reaaaaaly enjoy in this constest

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

The statement of D is so poorly written. It took me 20 minutes to understand that every $$$k$$$ consecutive elements of $$$A$$$ and $$$B$$$ are permutations of $$$1$$$ to $$$k$$$.

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

What's wrong with my C 317997945

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

how did you guys solved c ??

void solve()
{
    int n;
    cin>>n;
    vi a(n);
    for(ll&i:a)
    cin>>i;
    vii pos;
    for(int i=0;i<n;i++)
    {
        pos.push_back({a[i],i});
    }
    sort(pos.begin(),pos.end());
    vi temp;
    for(auto it:pos)
    {
        temp.push_back(it.second);
    }
    multiset<int>clone;
    int cnt=0;
    while(!temp.empty())
    {
        int x=temp.back();
        temp.pop_back();
        if(clone.count(x+1)||clone.count(x-1))
        {
            clone.insert(x);
            continue;
        }
        clone.insert(x);
        cnt++;
    }
    cout<<cnt<<'\n';
}

this is mine please tell me where it is going wrong

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

Struggled for A more than B,C. Overall its a good contest, atleast for me w.r.t A,B,C

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

Finally a contest where accepted solutions for A, B and C seems human rather than LLMs

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

As a participant I Realllly enjoy in that constest

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

What was tc 4 in D, kept getting Wrong answer on it T_T

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

casework for B is like sooo worst

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

Overall good contest, was able to solve A,B,C.

I was trying to solve D using binary search, and was not able to implement it during the contest, will upsolve. Anyone who has done it using Binary Search???

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

EdgecaseForces

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

what the hell is the 7th test case for D?

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

E was easier than B imo

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

Rating is going to take a huge hit after this round. I can usually solve atleast 1-2 questions in div2. Could not solve any this time :(

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

Wasn't there supposed to be a contest on saturday(3rd of may)?

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

very good Div1 guys

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

very good Div1 guys

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

can someone tell why my solution for c is failing ? 318011548

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

Amazing problem D ! thanks for the authors for that but I which C and B was more interesting.

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

Worthless idiot like me deserve to be butchered like a pig. I practice and solve 2200+ rated problems without editorial and get 2000 performance in virtual, then reality says fuck you and I don't solve Div2B. Every time I do virtual it's CM performance but real contest I get 1600? Why? I love solving problem but every time I do contest I get severe depression the whole day after, maybe best I quit CP before I develop some mental disease.

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

    dont be so hard on yourself.. keep practicing .. it will take some time.. but it will improve..

    anyway if you are able to solve 2200 problem I should not give you advice... lol

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

    this B was just a bunch of casework and the contest overall was bad, did you try solving C or D after not being able to solve B? you probably got really panicked after not being able to instasolve B and then you ruined the entire contest. i couldnt instasolve A this contest, and i coyuld have panicked as well, but you really just have to keep calm and relax in those situations. and in the end after taking 10 minutes to solve A, i had a CM performance, because i kept calm and read B before returning to A with a clear mind. all of this will come with experience and you shouldnt beat yourself up after a bad contest. especially since you really have nothing to lose in these contests except virtual points. making mistakes is important in these online contests, so when you do irl contests you can avoid them

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

    c was trivial compared to b...

    so yeah b is a really ugly outlier (stress test forces)

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

pretty bad contest, speedforces with ABC, and then a really hard D. i find D really cool even though i didnt solve it, and i think i will enjoy upsolving a lot, but the overall balance of the contest is terrible(even though this is my best performance ever in any contest and i think i will even reach expert lmao)

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

When is editorial coming out??

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

can someone help me about how can i try and run the first testcase of interactive types problem?

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

Image

Tags for A are trying to say something

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

banger round, one of my favs thus far <3 thanks to the writers and testers orz

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

Trolled myself in C

only after finishing the buggy implementation did i notice you could move any clone, not just the newest one

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

A -> observation, Maths B -> Bit Manipulation. Greedy

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

how do you solve E? is it just look at the diameter and remove a leaf not on diameter, otherwise remove a leaf on diameter? or is there more lol

also ty contest creators, not bad round + i promoteforces :]

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

    Consider the tree, rooted from it's centroid, in this case lca of each pair with same color is root of the tree and we should merge the vertex $$$v$$$ with the minimum $$$h[v] + sz[v]$$$, where $$$h[v]$$$ is the number of edges from $$$v$$$ to root and $$$sz[v]$$$ is size of the subtree with root $$$v$$$.

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

For $$$D$$$ 121/122 queries are enough

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

Ordering of B and C should be swaped .... . Problem B was a little nightmare ..........

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

Excuse me, why do I get a Memory Limit Exceeded (MLE) error in this C programming problem? 318031123

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

D was a very fun problem, probably one of my favorites!

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

S

»
17 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...)
#endif

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    
    int Q; cin >> Q;
    do [&](){
        int n;    cin >> n;
        
        vector<pair<int, int>> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i].first;
            a[i].second = i;
        }
        sort(a.begin(), a.end(), greater<>());

        dbg(a);

        set<int> S;
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            if (!S.contains(a[i].second-1) and !S.contains(a[i].second+1)) ans++;
            S.insert(a[i].second);
        }
        cout << ans << "\n";
    }(); while(--Q);

    return 0;
}

Can you please tell why this algorithm failed on C?

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

    The code below works (318056161). I just removed non-unique consecutive elements.

    Code


    Your code fails on this test case:

    Test

    Basically it marks first $$$5$$$ (and increase the answer). Then it goes to the last $$$4$$$ and as the middle $$$4$$$ is not marked it increases the answer again. So it gives the answer $$$2$$$, instead of $$$1$$$. We go $$$5 \,\rightarrow\, 4 \,\rightarrow\, 4$$$.

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

Is there a more straightforward observation to get the answer for A? I had to do the following:

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

    When I was solving, I just guessed the answer. After the contest I came up with this:

    1. The minimal value is when $$$p_i = i$$$ and that's $$$0$$$.
    2. Let we have an array $$$c$$$ that has all elements from $$$1$$$ to $$$n$$$ twice ans sorted, like $$$ [1, \, 1, \, 2, \, 2,\, \dots, \, n,\, n ]$$$. When we open absolute value parentheses, there will be $$$n$$$ and $$$n$$$ values with plus and minus. The best is to have last $$$n$$$ with pluses and other with minuses. That's possible with pairing $$$c_i$$$ with $$$c_{2n + 1 - i}$$$ for all $$$1 \leq i \leq n$$$ (so $$$[1, n], \, [n, 1], \, \dots$$$).
    3. Let's take any permutation. When we swap two consecutive elements we increase the value by either of following $$$[-2,\, 0,\, 2]$$$. So going from $$$p_i = i$$$ to $$$p_i = n + 1 - i$$$ by swapping two consecutive will lead to visiting all values from $$$0$$$ to max. As we can't have odd values (because we increase by even value each time) the answer is $$$\frac{\text{max}}{2} + 1$$$.
»
17 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Observation of 'A' was just a nightmare..!

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

Great contest. Thanks!

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

I read the Problem C for an hour.I thought the clone means another copy of a button. What can I say.