Блог пользователя myst-6

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

Hello Codeforces! Me and yud08 are excited to invite you to take part in Codeforces Round 982 (Div. 2), which starts on Oct/26/2024 17:35 (Moscow time). You will be given 5 problems and 2 hours to solve them. Two problems are divided into two subtasks.

This round will be rated for all participants whose rating is strictly below 2100.

The problems were authored by me and yud08, and prepared by me.

We would like to thank:

We hope you enjoy the problems!

Score Distribution: $$$500 - 1000 - 1250 - (1250 + 1000) - (2000 + 1000)$$$

We actually wanted to continue the trend of posting photos of contest writers, but we could only find one photo containing both of us, which was a group photo that we took with some other UK informatics people! (I'm the one in the back of the picture who is wearing the MHC T-shirt and yud08 is the one whose head is popping out from the left side of the photo.)

20240921-153321

UPD1: Congratulations to the winners of the contests:

Div 1:

  1. jiangly
  2. neal
  3. SSerxhs
  4. A_G
  5. kotatsugame

Div 2:

  1. nathan_higgs
  2. puru-puru-pururin
  3. Nonoze
  4. Hong_Meiling
  5. Nika_Tamliani

Also, first solves! (if any of these are wrong please let me know)

UPD2: Editorial is available here

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

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

As a tester, this is my first "as a tester" comment.

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

Since we all know real Codeforces rating is actually determined by rating * contribution, as a writer, give me contribution.

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

As a tester, the contest is very good and I like all the problems!

Also, orz myst-6

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

as a tester, i swear on skippity problem F can be solved by binary searching a segment tree and morphing the result into a dsu before finally getting the answer using a mixture of crt and fft (alternatively you can use a persistent 1729-dimensional convex hull trick on a sparse segment tree)

Also, orz myst-6

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

As a tester, do not miss the contest.

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

Love the photo! Who are the other mysterious coders in it? One of them has a blank screen. We need to know :)

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

As a tester, just put the contribution in the comment bro

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

Another quick chance to re-perform after all these greedy pains and hacks on map... Hope to reach pupil again this time

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

Last year I made the same question and still don't know why to make a contest on Ieeextreme day T~T Ik maybe it's not on clist but most of coders know about ieeextreme and its date. Anyway, Thanks authors for a new round ^-^

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

I am the camera

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

Whats (1250 + 1000). Can someone explain?

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

    It's a problem with a subtask, subtask of a problem means it will be a similar problem but with harder constant or condition.

    Another way to see it is 2250 problem being splited out into (1250 + 1000) for easier approach. Which aimed at weaker contestant to have a chance at solving (like me, the lower rating part).

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

LongTrainDiv2

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

As a tester, I love the problems! \(^▽^)/

Also, orz myst-6

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

wtf these guys look too chad to be studying cs

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

As a tester, I can confirm that problems have statements

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

clashes with lc biweekly

should I give cf div 2 or leetcode biweekly?

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

this is a really good practice of keeping the photos of people preparing the contest, it gives good vibes + i personally feel that yes in today's AI world still there is human interaction which makes me happy.

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

As a tester, I've purchased this contest for kids' enjoyment.

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

First CF after AFO.

CSP rp++ (CSP: a very important contest for Chinese OIers, just ended 30min ago)

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

Guys you giving LeetCode Biweekly or, Codeforces Div 2? Imma confused :(

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

myst-6 fasrsi baladi?

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

Is there gonna be a hacking phase?

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

Good Index.

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

hope i become specialist after this round :)

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

why is contest registration closed before the start?

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

Oh, speedforces today!

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

Any hints for E1? I feel like the nimber for each pile should only be revolving around $$$\text{popcnt}(x_i)$$$, but I hardly came up with anything...

Wasting 40min thinking about E1 while I could have been coding D2 should be one of the worst tactical decisions I've ever made XD

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

so close to solve C but failed...

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

Oh! Because I wasn't familiar with discretization, I lost a lot of ratings in this round.꒰╬•᷅д•᷄╬꒱

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

How do you solve C ? I couldn't solve it no matter what

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

Alright, so how to count the number of ways to achieve the result in D2? Struggled for an hour and still didn't get past TL8 (all other ideas just WA-ed).

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

    Take the DP table used to solve D1 (one with states [elements removed][value of $$$k$$$]). In this table, I'm assuming you found the minimal cost for each state by doing the minimum of costs required when increasing $$$k$$$ by 1, and when removing a prefix, where removing the largest one doesn't hurt.

    When increasing $$$k$$$ by 1, the number of optimal options assuming you do that is obviously just the number of optimal options for the state with $$$k$$$ greater by $$$1$$$.

    However, when removing a prefix, it's possible that removing a smaller prefix would also lead to an optimal solution. However, what you can note is that as the number of removed elements increases, the minimal costs required to finish are non-increasing. So, what you can do is first find the optimal cost, then use binary search to find the smallest prefix you can remove if you want to achieve that cost, and then calculate the sum of numbers of options for each prefix between the largest one with this cost and the smallest one with this cost (doable with suffix sums).

    Now, just compare the minimal costs obtained by increasing $$$k$$$ and by removing a prefix, if they're unequal, take the smaller one and the number of options for that operations, and if they're equal, take that cost and the sum of numbers of options for both of these operations.

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

How do you do C? I tried a graph solution but it was too slow.

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

i got so confused on B, worst performance in a while. i found C pretty cool, and D1 seems doable, but i just wasted too much time on B. nice round

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

hints for D1??

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

How to solve A? Really do not understand why my solution was wrong.

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

Awesome B. Cost me 1 hrs + 3 WAs. That B is fucking hard, C is much easier. I think D1 is easier than B, but I have no enough time to solve it.

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

wtf was b's solution? I know im sleep deprived, but im felling dumb af

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

    Say x is at index i then all the elements after index should be smaller than x. And for all the elements before index i, we only care about the elements before the maximum element upto index i, we will need to remove all those.

    288132226

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

      idk if I understand it well, but thats basicly what I did I kept searching for the max element on the vector, then I removed all the elements from the right of it

      Then i searched again for the max element up to index of the last max and on and on

      Then my answer was the number of max elements — the max element between the max elements it passed only test 1

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

        alright so lets take an example

        3 6 9 4 2 5 2

        say i am checking for index, i = 5 (1 based indexing), so the idea is to make both the right side (i>5) and left side (i<5) suitable but i handled that sepertaely

        for the right side, so the no of elements greater a[j] > a[i] such that j>i is simply 1, i.e., only 5( for j =6)

        for the left side, the ideal way is to remove all the elements before the maximum upto i = 5. so the maximum upto i = 5 is 9 and no of elements before it is 2.

        so total = 1 + 2 = 3, so if i had to make i = 5 as sort of the "center" of my arrangement then i need to remove 3 elemnts

        Now i will run this algo for all i from 0 to n and keep on taking the min for it

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

    Since n is small, you can count for every index i, number of a[j]>a[i] such that j>i by brute force.

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

    brute force the following for each i and pick the minimum:

    i + # elements a[j] (j > i) such that a[j] > a[i]

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

I printed lots of pairs $$$(n,k)$$$ on problem E1 and try to guess answer, it takes me 2 hours, just for 1000 points?

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

As a newbie, I am just never able to solve B (crying emojis)

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

    Don't cry for things out of control, you can start with some easier problems or exercise thinking skills. It's unnecessary to worry about how many problems you have solved but how many skills you have learnt.

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

Problems A, B and C were pretty good, but D1 is too easy. It is a really standard DP problem. Also speedforces.

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

All dp? Solved B, C, D1 with dp.

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

How to solve E1? My code is timing out when computing the SG function. Can someone help me?

#include <bits/stdc++.h>
 
#define int long long
 
constexpr int N = 1e5 + 6;
 
int mex(std::set<int> &s) {
  int m = 0;
  while (s.find(m) != s.end()) ++m;
  return m;
}
 
std::map<std::pair<int, int>, int> mp;
 
int SG(int x, int a) {
  if (x == 0) return 0;
  if (a >= x) return __builtin_popcount(x);
  if (mp.count({x, a})) return mp[{x, a}];
  std::set<int> s;
  int d = x;
  while (d > 0) {
    if (d <= a) {
        s.insert(SG(x - d, a));
    }
    d = (d - 1) & x;
  }
  return mp[{x, a}] = mex(s);
}
 
void solve() {
  int n;
  std::cin >> n;
  std::vector<int> a(n + 1, 0), x(n + 1, 0);
  for (int i = 1; i <= n; ++i) std::cin >> a[i];
  for (int i = 1; i <= n; ++i) std::cin >> x[i];
  int ans = 0;
  for (int i = 1; i <= n; ++i) ans ^= SG(x[i], a[i]);
  std::cout << (ans ? "Alice" : "Bob") << "\n";
}
 
int32_t main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0), std::cout.tie(0);
 
  int t;
  std::cin >> t;
  // t = 1;
 
  while (t--) {
    solve();
  }
 
  return 0;
}
»
18 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I don't understand why B's constraints are low when a non-n^2 solution is not hard to do and fits a div2 B. (Yes, I am annoyed that I didn't look at the constraints, which is totally my fault).

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

    I think that a better solution than $$$O(n^2)$$$ is a bit too hard for div2B (some people are already saying it was too hard). Maybe having an easy version where $$$O(n^2)$$$ passes and a hard version where it doesn't would work better?

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

    What is the 'fits a div2 B' solution? I see you used pbds to find the order and that is definitely not D2B level. It's more like a D2D.

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

      Well, finding the number of greater elements to the right is too standard to be a D2D, and yes it will be a slightly harder B but will make it not a speedforces at least. And making it a B1B2 is a great idea as the other reply mentioned. (And after considering now, yes the constraints is just alright I was just salty I didn't focus on it)

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

        It adds almost nothing to the problem other than having to know a very standard technique. We don't want a D2B-level idea problem to require a D2D-level data structure, just because a solution for the harder version using such a structure exists.

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

          To be fair, a lot of data structures other than pbds can also solve this in $$$O(nlog(n))$$$ (there are at least $$$2$$$ different segment tree solutions, for example), but I still definitely agree that having this as just div2B would be too hard, and my easy/hard version idea probably isn't actually that great either.

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

couldn't solve B

I'm screwed

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

For B I was trying to get traverse till the first decreasing slope (i,e. traverse till A[i] < A[i+1]). And then my peak would be A[i]. Any number greater than this peak also is to be deleted. This failed on pretest(3). So I would love new ideas ?

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

288174453 When I submit D2 at the last minute:

Passed pretests 1-7 ... :)

MLE in 8 :((

Lesson: use vectors to handle DP with uncertain array lengths ; )

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

How to solve D1

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

    You can solve it using DP + Prefix sum, it will run in either $$$O(N * M * log_2(N))$$$ or $$$O(N * M)$$$.

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

Can someone tell me what's wrong with my D1?

Solved it. nevermind

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

D2 is a good problem.

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

jiangly ORZ :0

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

Why $$$O(n^2)$$$ in B, eventhough it's easy to solve in $$$O(n)$$$ ?

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

I finally solved C by sorting the edges, but I wonder why the bfs solution got a TLE?

288136031

I used discretization to avoid map<ll, vector<ll>>, but then I got 3 MLE :(

288160146

Can anyone help me with the time complexity or the memory use of my solution?

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

Could someone please explain their D2 approach?

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

Did anyone solve C with DP? Please share your approach!

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

Very inspiring contest! I love it!

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

I'm like a little baby,don't konw d1 why?

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

dpforces

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

Thank you very much for the contest.

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

ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh i passed c with map but got tle with umap ahhhhhhhhhhhhhhhhhhh

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

Nice shirts :)

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

For Problem C, I submitted the same code in contest, it got TLE'd. And when I submitted the same solution in practice, it got accepted.

Can anyone explain the reason behind it? Thank you!!

TLE submission

Accepted submission

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

Solved A & B in 8 minutes but couldn't do C because I forgot to keep track of visited for my BFS solution :(

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

I reached blue with this one :D

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

I just want to understand, how my rating dropped if I solved 1 problem (A) say (+100pts) and then gave 1 wrong submission on B (-50pts). I got -44 delta. So I'll be glad if someone explains the drop.

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

I hate DP

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

Problem C, Most of the codes have used dfs, I used bfs and got MLE.

I used the same adjacency list as others using map. The map will contain atmost 3e5 elements, The queue can have a maximum of 3e5 elements at a time. So that shouldn't give MLE. What am I missing here?

Submission Link : https://mirror.codeforces.com/contest/2027/submission/288164685

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

Overall very nice round!

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

Tomorrow morning КГБ knocks on the door of the author of problem B (Stalin Sort)...

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

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

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

I liked the contest, (luckily) there wasn't much diff for me between $$$D1$$$ & $$$D2$$$.
What is the chance of getting $$$+3$$$ or more after rating roll back?

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

please rename title of contest as "Educational DP Contest — AtCoder"

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

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

Wait who even consensually name themself nathan_higgs like this name is weird man

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

How to do B if the bounds were more strict?

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

I would like to report suspected cases of cheating in Codeforces Round 982 (Div. 2). I have identified multiple pairs of submissions with identical or nearly identical solutions. Here are the relevant submission links:

Pair 1: https://mirror.codeforces.com/contest/2027/submission/288161794 https://mirror.codeforces.com/contest/2027/submission/288145385

Pair 2: https://mirror.codeforces.com/contest/2027/submission/288152323 https://mirror.codeforces.com/contest/2027/submission/288137323

Pair 3: https://mirror.codeforces.com/contest/2027/submission/288163896 https://mirror.codeforces.com/contest/2027/submission/288155729

Each pair of submissions shows a high degree of similarity.

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

Finally, I'm Pupil!!