CutieSmileHaruka's blog

By CutieSmileHaruka, 5 months ago, In English

Hello, Codeforces!

We are glad to invite you to take part in Spectral::Cup 2026 Round 1 (Codeforces Round 1094, Div. 1 + Div. 2), which will start on 25.04.2026 17:35 (Московское время). You will be given 8 problems and 2.5 hours to solve them. This round will be combined for Division 1 and Division 2 and will be rated for everyone. At least one problem will be interactive, so please make sure to read the guide for interactive problems before the contest.

All problems are authored by lizhous, Lyz09, ma2021tyoi0037, hzy_____ and me.

We would like to thank the following people for making this round possible:

The scoring distribution is $$$500$$$ — $$$1250$$$ — $$$1500$$$ — $$$2000$$$ — $$$2250$$$ — $$$3000$$$ — $$$3500$$$ — $$$4000$$$.

UPD: Congratulations to the winners!

  1. Radewoosh
  2. jiangbowen
  3. XVIII
  4. maroonrk
  5. Nachia
  6. Ormlis
  7. PCTprobability
  8. potato167
  9. superguymj
  10. NanYan

UPD: The editorial is out!

Now a few words from our sponsor.

Spectral Technologies Spectral::Technologies is an HFT fund – we build trading strategies and low-latency infrastructure for global markets. The people doing this: IMO, IOI, IPhO and All-Russian Olympiad medalists and top engineers – people who love the challenge and always want a bigger one. That's who Spectral was built for.

We are actively hiring! Check out our Quant roles:

We’re also hiring for C++, ML, and DevOps roles. Complete the application form to explore career opportunities with us.

Apply

We are excited to sponsor this Round as part of Spectral::Cup 2026 — a three-round tournament where prizes get more valuable with every round.

Prizes for Round 1:

Top 30 will get merch bags with stickers and personalized t-shirts.

Make sure that you take part in all three rounds to improve your chances to get the main prizes. We prepared bigger prizes for top performers by their final score in Spectral::Cup 2026. The final score is the sum of your best 2 results according to the GP500.

  • Top-3 by final score will get (1st) MacBook Pro, (2nd) iPad Pro, (3rd) Whoop — or USDT equivalent to the prize value
  • Top-15 by final score will get Claude subscription
  • 30 random participants among top 500 based on the final score will get additional prizes

Code fast, think faster – see you in the next round of Spectral::Cup 2026!

  • Vote: I like it
  • +179
  • Vote: I do not like it

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

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

»
5 months ago, hide # |
 
Vote: I like it +42 Vote: I do not like it

Please do not leak the problem statements like Tsinghua University did...

»
5 months ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

Seems pretty well-prepared. Hope this doesn't get leaked and unrated!

»
5 months ago, hide # |
 
Vote: I like it +37 Vote: I do not like it

Why reject my awesome problems :(

»
5 months ago, hide # |
 
Vote: I like it +16 Vote: I do not like it

As a tester, please be kind to me because my rating is not 1300.

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

I really hope this turns out to be a good contest :/

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

Look interesting! I hope the contest will be well-prepared with complicated and engaged problems.

But I have several questions about job offer: in the post we can see salaries, but I do not understand the final amount of money Quant will have after taxes per month (because it is strongly depended on office location and payments mechanism: fix per month salary or result-dependent bonus)?

The second crucial question: how many hours Quant have to work per day to perform well for the expected reward?

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

    Hey, thanks for the questions!

    On compensation: the final take-home does depend on office location and local taxes, but the range in the post can actually be your net, since we also hire in 0% income tax jurisdictions (and fully sponsor the relocation).

    On top of that fix, there's a profit-share bonus — it comes in addition to the range, not inside it.

    Location is best discussed with our recruiters directly, since it depends both on the position and the candidate.

    On how much a Quant needs to work to get that amount: 1) the range you see in the vacancy is fully fixed; 2) we pay bonuses for results, not hours. But we've checked today with the team, and our Quants work 40-45 hours per week = 8-9 hours per day :)

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

Good luck & Have fun~

»
5 months ago, hide # |
 
Vote: I like it -46 Vote: I do not like it

As a fan of CutieSmileHaruka, please be kind to me cuz my codeforces rating is only 1400

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

Hope this contest doesn't get leaked and unrated!

»
5 months ago, hide # |
 
Vote: I like it -76 Vote: I do not like it

Can I reach GM this time? @_@

last time I got hacked because hash and lost GM. T_T

Good luck everyone!

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

Do you actually hate people with cyan color???

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

As a stupid tester, hope you‘ll have fun with those tasty tasks. QwQ

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

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

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

Keep it up my brother and coach Mahmoud-Atia <3

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

as a tester (who tested after the blog post was posted), idk what to write but the round is pretty nice

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

Are there any interactive problems or run-twice problems?

It seems that the blog hasn't mentioned...

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

    can you please explain C

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

      The solution is clearly based on dynamic programming.

      At first, I used my standard median-maintenance template, but its time complexity was $$$O(n^2 \log n)$$$ , which was too slow.

      Then I noticed that after coordinate compression, the maximum value is small, less than 5000, so I rewrote the median part using a frequency array.

      The key observation is that the median of any subarray must be one of the values appearing in the original array, so we only need to consider those values.

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

        Nice observation!

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

          Sorry, the meaning of the observation has changed when translating into English.

          It's the median of any subarray must be the median of the array.

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

        I see your accepted code, but I think it's $$$O(n^3)$$$. Because in you rewroted part median can jump from $$$1$$$ to $$$n$$$ and back.

        In input: $$$1, n, n, 1, 1, n, n, ..., 1, 1, 2, 3, ..., n-1$$$.

        There are $$$n$$$ switching blocks: $$$1, 1$$$ and $$$n,n$$$. At the end numbers from $$$2$$$ to $$$n-1$$$ for anti coordinate compress. Total length: $$$1 + 2 \cdot n + (n-2) = 3 n -1$$$.

        If we start median-maintenance from index $$$0$$$ then: median for subarray $$$[1]$$$ is $$$1$$$, for $$$[1, n, n]$$$ is $$$n$$$, for $$$[1, n, n, 1, 1]$$$ is $$$1$$$ and so on. In your code this median switching needs $$$n$$$ iterations in frequency array. In total we have $$$n$$$ blocks ($$$1, 1$$$ and $$$n,n$$$).

        So start from index $$$0$$$ require $$$n^2$$$ iterations in frequency array. Same with indexes $$$2, 4, 6, ...$$$ . So total operations: $$$n^2 + (n^2-n) + (n^2-2n) + ... = O(n^3)$$$.

        Unfortunately, I not found hack-button so can not to check.

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

          Thank you for your advice, but I think the example is wrong?

          After I compressed the array, the elements should be $$$1,m,m,1,\ldots,1,2,3,\ldots,m-1$$$ , when $$$m$$$ is the size of the array after unique.

          Btw, there is a hacking button in my submission. If you clicked into my submission, you can see it:)

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

          I think the concern comes from assuming the median jumps arbitrarily each time.

          However, since we use a frequency array over a compressed value range (≤ 5000), the median pointer does not reset and scan the whole range every time. It moves incrementally based on frequency changes, so across all transitions its total movement is bounded.

          Because of this amortization, the total complexity does not blow up to O(n 3 ), but stays within acceptable limits.

»
5 months ago, hide # |
 
Vote: I like it -15 Vote: I do not like it

a

»
5 months ago, hide # |
 
Vote: I like it +27 Vote: I do not like it

Top 15 might already have Claude subscription ;)

»
5 months ago, hide # |
 
Vote: I like it -10 Vote: I do not like it

wow

»
5 months ago, hide # |
 
Vote: I like it +31 Vote: I do not like it

The final score will be calculated based on your best 2 results.

Could you elaborate on the exact method to combine two results? For example, when person X gets 1st and 3rd and person Y gets 2nd and 2nd, which one would be considered better?

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

This contest has a lot of cheaters.

Update:I was wrong. It turns out there are a lot of excellent specialists here who monitor this. Thank you so much for not allowing cheaters into the contest.

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

GKarthik26 is a heavy cheater as he switches between multiple programming languages during the contest. He became grandmaster in 7 contest only. MikeMirzayanov Ban him.

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

    idontwannadothisanymore is also a cheater as he became grandmaster in 5 contest only.MikeMirzayanov Ban him.

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

      Of course we did notice this account, of course we checked it. I checked it once more, I can't see anything telling this is a cheater and not a strong participant. If you have an actual proof, share it please, what you just said doesn't proof anything.

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

        idontwannadothisanymore and NahIdGetHired submitted almost the same code. The only noticeable changes are variable names and small changes in if-else statements, which seem to be done to evade the plagiarism detection tool. I have attached the proof, and you can also compare both users’ solutions. The logic and structure of their code are highly similar, so I request the contest administrators to review these submissions.

        idontwannadothisanymore [submission:https://codeforces.me/contest/2170/submission/351041746]

        NahIdGetHired [submission:https://codeforces.me/contest/2170/submission/351033870]

        screenshot

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

      XVIII appears to be a very clever cheater and has allegedly been cheating for the past seven months. One of his previous contest solutions was skipped, which gives strong proof of suspicious activity. He also used multiple programming languages during the contest. After today’s contest, he may become the first cheater to reach LGM in only seven months.MikeMirzayanov Ban him.

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

    Hi, I am That GKarthik26 writing this comment/post from alt account

    MikeMirzayanov tagging you here because I genuinely want clarification regarding this accusation and the resulting ban.

    Saying that I am a “heavy cheater” simply because I switched between programming languages during contests does not make sense. I mainly use Python and Rust, and I occasionally used C++ earlier depending on the problem and performance constraints. Many competitive programmers use multiple languages.

    I also do not understand how using two languages during contests can itself be treated as suspicious, or even be described as “multiple programming languages” in the context used by SherlockHolmes007

    Also, several people upvoted the accusation, so I want to ask clearly: what exactly is the proof or justification behind it?

    My submissions are public and can be checked directly for plagiarism, suspicious similarities, or AI-generated patterns.

    I already had a strong programming background before Codeforces:

    • Top 0.9% on LeetCode
    • 6★ on CodeChef
    • Backend engineering experience

    I have already sent appeals and tried contacting admins/moderators, but I have not received any clarification yet. I am simply asking for transparency and evidence-based judgment instead of assumptions.

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

Aaaaaaaaah! I really wanted to participate this contest!!!!! I missed the chance.. oh man!!

»
5 months ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

ngl i loved it!!!!!

like this was the first time when Problem A was challenging and it took me approx 2 hour to solve it and the movement when it clicked!!!!, the happiness was unimaginable

so thanks developers!!

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

    idk why A works, but it worked on the samples => solution proved

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

    just think about the last 100 ex if total 800 then 701-800. You can only make those last 100 if you have a[i]=100 in the array.

    Also why just one a[i]=100 is sufficient its because it allows 0-100 be formed and then lets say for 101-200 we will make something else 100 by taking it fully and this a[i]=100 to make 101 to 200.

»
5 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

I feel like E is easier than D, though the numbers of submissions tell another story. Anyway my best contest so far and loved the problems

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

I'm so stupid or really need Fenwick (or some uncomfortably link sew for $$$O(n^2)$$$) to solve C?

»
5 months ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

Nice round.

Unfortunately there was not enough time for writing dynamic connectivity offline for F.

Why is time limit so tight on C? I spent too long trying to optimise it and it will likely still FST.

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

    I spent so much time worrying that $$$O(n^2 logn)$$$ would TLE for C... The TL just doesn't seem like intended for $$$O(n^2 logn)$$$, should be 3 sec.

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

      $$$O(n^2)$$$ is probably intended, I was also doing extra $$$log(n)$$$ untill I realized only possible median is the median of whole array

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

    It was a test for whether or not you know how to optimise constant behind $$$O(n^2\log(n))$$$ asymptotic of your solution. In this problem you can use priority_queue instead of multisets to easily fit into the time limit: 372488797

    And if you can't optimize constant, you can go for optimizing asymptotic itself as there are exists $$$O(n ^ 2)$$$ solution.

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

    Yeah I don't like being stuck in the limbo state of either "find the n^2 solution that may or may not exist" or "you just have trash constants on your n^2 log n". I wish time limits were a bit more clear. Like either n=9000 or n=2000.

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

    I think they were trying to cut $$$O(n^2\log n)$$$ solutions to force observation

»
5 months ago, hide # |
 
Vote: I like it +20 Vote: I do not like it

Very good contest! I really love D and F!

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

what was the idea for D?

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

    Check prefix sums. Notice pattern. Test pattern on examples. Sort + print = profit

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

    Forget about finding the best permutation. For a given permutation, what would be the answer?

    For an inversion (i, j) where i < j and p[i] > p[j], the contribution of this inversion is prefSum[j-1] — prefSum[i-1]. So let's find out for each index i = 1 to n how many times it will contribute +prefSum[i-1] and how many times -prefSum[i-1].

    Let: cntLeftGreater[i] = number of indices j < i with p[j] > p[i] cntRightLesser[i] = number of indices j > i with p[j] < p[i]

    Notice that the net coefficient for prefSum[i-1] is exactly (cntLeftGreater[i] — cntRightLesser[i]). This actually simplifies to (i — p[i]).

    Why??

    1) cntLeftGreater[i] + cntLeftLesser[i] = i — 1
    2) p[i] = cntLeftLesser[i] + cntRightLesser[i] + 1

    From equation (1), cntLeftLesser[i] = i — 1 — cntLeftGreater[i]

    Substitute this into equation (2):

    p[i] = (i — 1 — cntLeftGreater[i]) + cntRightLesser[i] + 1

    p[i] = i — cntLeftGreater[i] + cntRightLesser[i]

    Rearranging the terms gives us exactly what we need: cntLeftGreater[i] — cntRightLesser[i] = i — p[i]

    So, the total cost for any given permutation just boils down to: Sum over all i from 1 to n of: prefSum[i-1] * (i — p[i]).

    Notice that the prefSum[i-1] * i part of the summation doesn't depend on the permutation. We just have to minimize the summation of p[i] * prefSum[i-1]. To do this, we greedily assign the largest prefSum values to the smallest p values (a consequence of the Rearrangement Inequality).

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

I spent 2 hours to think E and got WA2. It's still "a wonderful contest".

»
5 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Why does Order Statistic Tree get TLE on problem C? I don't have template for BIT and it lost me soooo much time, just for the same idea but different implementation

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

    Well i think the intended solution was just a O(n^2) dp. I don't see the need for OST or BIT

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

Is F some data structure thing? I feel like the round lacks a strong logic problem for a Div1...

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

Great problems and great round, but it is quite difficult... I use a long time to solve B and D.

»
5 months ago, hide # |
 
Vote: I like it -8 Vote: I do not like it
#include <bits/stdc++.h>
// #define int long long
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n;
int a[5001], meds[5001], dp[5001];
Tree<pair<int, int>> e;

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

  for (int i = 0; i < n; ++i) meds[i] = a[i];
  sort(meds, meds + n);

  int median = meds[n / 2];
  fill(dp, dp + n, 0LL);
  for (int i = 0; i < n; ++i) {
    e.clear();
    for (int j = i; j >= 0; --j) {
      e.insert({a[j], j});
      if ((e.size() & 1)) {
        auto it = e.find_by_order(e.size() / 2);
        auto v = *it;
        if (v.first != median) continue;
        if (j - 1 < 0) {
          dp[i] = max(dp[i], 1);
        } else
          dp[i] = max(dp[i], dp[j - 1] > 0 ? 1 + dp[j - 1] : 0);
      }
    }
  }

  cout << dp[n - 1] << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int T = 1;
  cin >> T;
  while (T--) Main();
}

Can somebody explain how to optimize C, my O(n^2*log(n)) solution got TLE on pretest 5.

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

I submitted G at 2:28:44 then got Pretest passed with 2000 / 2000 ms. I think I'm going to get TLE in system test :(

Upd: I was so lucky that the submission passed in 1953 ms! :)

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

What was the problem with the interaction protocol in E? I didn't have any as I submitted the solution, as a result I needed to do ~30 submissions all of which had WA1 just to understand what was wrong. Turns out in the beginning we have $$$S = {a}$$$, not $$${f(a)}$$$. My bad guys, we always insert $$$f(x)$$$ but suddenly in the beginning we have the number itself. Without any protocols it was really hard to find, which ruined the contest for me. It was incredibly annoying, considering that I found the first 5 tasks really good.

»
5 months ago, hide # |
 
Vote: I like it +20 Vote: I do not like it

Screencast(with audio) of me struggling, but managing to solve A and B.

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

Does greedily selecting values until it achieves a median of $$$v$$$ (the current value you want the subsegment's median to be) not work? I had a template for sliding window median.

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

    Consider the testcase: 7 7 7 7 5 5 5. If you do what you mentioned, you won't get any valid partition.

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

    Consider the array 3 2 2 1 1 2 2 Now according to your logic your first cut would be at 3 2 2 and now you are left with 1 1 2 2 which wont satisfy our given condition. Optimal solutions is 3 2 2 1 1 || 2 || 2

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

guesswork D

»
5 months ago, hide # |
 
Vote: I like it -58 Vote: I do not like it

Why do Chinese always create such garbage questions? Please stop embarrassing us on the international stage, OK?

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

    Which problem is "garbage"? I think you shouldn't call the question bad just because you can't solve it yourself.

»
5 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

C was a great problem, tracing the median value was fun.

»
5 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

why is F's implementation so hard....

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

Raise hand who all wasted time in B? I wasted so much time to debug...... only to find i missed case when there are zero operations on either of odd or even indices group

»
5 months ago, hide # |
 
Vote: I like it -30 Vote: I do not like it

chinese rounds are always so cool and fun to solve, thanks for the beautiful problems.

»
5 months ago, hide # |
Rev. 2  
Vote: I like it -26 Vote: I do not like it

gptforces

»
5 months ago, hide # |
 
Vote: I like it +67 Vote: I do not like it

Maybe it makes sense to talk about an elephant in the room. I think I've never noticed anybody resubmitting as often as I do whenever I'm close to the time limit — maybe because in the past usually pretests weren't equal to systests, but also mostly because the execution time fluctuates. So whenever (even assuming pretests = systests from now on) I decided to resubmit something and saw somebody who didn't, getting lower time on systest than on pretests (so having an even bigger safety margin), it felt weird that I'm kind of being punished for being cautious while somebody is being somehow "lucky". And today's situation is particularly interesting — those are my submissions:

The time of the last one increased from around 7.3s to 7.9s — so what, a clutch move with the resubmission? Hard to say — for other people I've seen even times less by 1.7s than during the pretests.

So my point is — this feels kind of like a randomness? I'm not sure where do those differences between the times on pretests and systests come from, but I'm not sure whether it's good and "fair" if we are unable to reason about "what our time during the systests will be".

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

    Huh, I've just noticed this blog. Are you saying (by as it seems, rejudging this guy's submission just like that instead of leaving him with TLE as expected), that every time when I was resubmitting because I was afraid of the time going up and losing points because of that, it was pointless?

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

      According to this blog: " Because of how Codeforces works, when a code gets TLE, it will rerun the code several times to see if the code is on the edge of the time limit. By doing this you increase the chances of your code passing significantly!"

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

        I know this trick, but it already showed him TLE, right? The main loop goes over all tests and if one of them gets TLE, then only this one test is rejudged and the main loop continues, right? This case is like a rejudge of a whole submission after already deciding that it got TLE (or at least I understand it like that).

        Also I'm not sure how is it connected with the times changing by more than a second.

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

          Hmm getting a rejudge when you already have a system in place is kinda unfair

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

C is funny!

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

Can someone explain why 372483665 this submission for B gets WA when it should be getting RE? As far as i can tell, the only problem is that the code is trying to access elements beyond the size of the vector. This verdict costed me precious time during contest :/

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

I used segment tree for C

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

Can someone tell me why greedy solution failing for the problem C.

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

    Your greedy approach fails because it completely ignores the original order of the array. The problem requires partitioning into contiguous subarrays. By just counting < mid and > mid globally, you assume you can rearrange elements freely, which is incorrect. Instead, you need to map the elements to +1 and -1, compute prefix sums to track the balance, and use DP to find the optimal valid contiguous partitions.

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

I don't think it was a Div1+Div2, it felt more like Div1 difficulty.

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

Does O(n^2 log n) pass for problem C in C++? I used a segment tree to calculate medians in logn time over n^2 subarrays.

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

When is the editorial going to be published?

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

Failed on Problem C... I thought that it could be simply solved by greedy and then my Expert dream broken...

What's more surprising, I passed E and C quickly after getting up. What a pity...

If you're familiar with bitwise operation and brute force, maybe it seems that E would not be very hard?

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

    Sorry to hear that :( Wish you become expert in the upcoming rounds.

    Btw I noticed that the number of problems solved on your accounts is low,so I am curious what website do you use for cp training?

»
5 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

E is a great problem.

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

My mind during contest they gave En^2<5000^2

me running in my mind 5000^2 *T so n^2 dp doesnt work in C

What a dumbo i am ....

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

How do you guys usually test/debug for interactive problems? I wasted way too much time on E this time

»
5 months ago, hide # |
Rev. 2  
Vote: I like it -25 Vote: I do not like it

I want to address the plagiarism flag on my 2222E submission. I coded this myself during the contest and I'll try to explain both why the solutions look similar and where they actually differ.

My submission: - https://codeforces.me/contest/2222/submission/372494337

Mentioned submission: - https://codeforces.me/contest/2222/submission/372508678

First, the similarity in the overall structure is honestly kind of expected for this problem. The query budget is n+3, and recovering c alone requires n queries since it can be any of 2^n-1 values. That leaves exactly 3 queries for everything else, which basically forces every correct solution into the same skeleton: set a=0, probe I 0 to separate k=1 from k=2/3, binary search for c with Q queries, then use the last 2-3 queries to tell OR and XOR apart. There's almost no room to do this differently and stay within budget, so the high-level structure converging is a consequence of the problem's constraints, not copying. The Q binary search loop also looks similar for the same reason. Recovering c bit by bit from the top is just the natural binary search, and there aren't many ways to write it. I'll admit this part of the code looks close between the two submissions, but I don't think that's surprising given how little freedom you have there.

Where I think the solutions clearly differ is the OR/XOR disambiguation, which is actually the part of the problem with real design freedom. My solution and the other one make completely different choices here. I split on whether popcount(c) >= 2. In the general case I take p = c & (-c), the lowest set bit, and issue a single I p. Under OR, f(p) = p|c = c which is already in S so the size stays at 2. Under XOR, f(p) = p^c which clears the lowest bit and gives a new element, so size goes to 3. For the special case where c is a power of 2, I find the bit index with __builtin_ctzll(c), pick an adjacent bit j, form x = c|(1LL<<j), and then issue both I x and Q x, using the Q result to decide.

The other solution splits on whether c == maxval. Their special case issues a hardcoded I 1 and reads the size. Their general case finds bit_in (lowest set bit) and bit_out (lowest unset bit), forms x = (1LL<<bit_in)|(1LL<<bit_out) and a threshold thr = c|(1LL<<bit_out), issues I x then Q thr, and uses the Q result.

These case boundaries don't overlap at all. My special case is exactly powers of 2. Their special case is exactly c = 2^n — 1. A power of 2 is never all-ones for n >= 2, and all-ones never has popcount 1. So for every value of c, the two solutions can take different branches and issue different queries. For example with n=3 and c=6, my solution takes p=2 and issues I 2, while theirs finds bit_in=1 and bit_out=0 and issues I 3 then Q 7. The only case where they happen to issue the same query is c=maxval where both end up doing I 1, but for entirely different reasons from entirely different logic.

I know the k=1 branch looks close too, but honestly that subproblem (probe each bit of an unknown number and accumulate) is about as standard as it gets algorithmically. Two people writing that independently are going to produce similar loops. The small differences are there though: I use a separate cur variable initialized to 1 to track the set size, they reuse the outer s variable. I accumulate with c += (1LL << b), they use c = threshold.

If one of us had actually copied from the other, the disambiguation logic would match since that's the hardest and most original part of the solution. It doesn't. I'm happy to provide anything else that would help review this, and I'm asking for it to be reconsidered.

»
5 months ago, hide # |
 
Vote: I like it +20 Vote: I do not like it

I recently received a notification claiming my submission was plagiarized, which I believe is incorrect and purely coincidental.

The only common part between my code and the mentioned submissions is the use of prefix sums stored as {sum, index} and sorting them. This is a very standard approach for this problem, and many independent solutions use the same idea.

The rest of my implementation is different. I constructed a graph from the sorted order and applied Kahn’s algorithm to generate the permutation. This step is actually unnecessary, and I later realized it was redundant, but I kept it since my solution was already working.

My submission:

Mentioned submissions:

My solution was written independently, and I don't see any similarity with the other submissions other than the above mentioned part .

I request a re-evaluation.

»
5 months ago, hide # |
 
Vote: I like it -11 Vote: I do not like it

I want to address the plagiarism flag on 2222D - Permutation Construction. I wrote complete code by myself during the contest. I believe this match is a structural collision caused by the mathematical constraints of the problem and standard C++ idioms, rather than copied code

The core logic of this problem relies on rewriting the inversion sum to calculate the contribution of each position. This naturally reduces the problem to a standard greedy assignment based on prefix sums. Because of this, the most optimal and standard C++ implementation requires a very specific sequence of operations:Computing prefix sums and mapping them to their original indices using {sum,index}.Using sort() on this vector.Greedily assigning values from N down to 1 in a single pass. It is one of the universally taught approach for this kind of problem for greedily assigning the value, as a result I think collision must have happened

My submission:

372509312

Mentioned Submissions:

372502371 372508062

I request a reevaluation.

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

Maybe it’s just me, but the “note” section of problem C should be fixed. How it renders on my screen for the first example is an underline under [3,3,2] and an underline of [2,4,3], which doesn’t make sense given the answer is 3. The same underline issue exists for the second example.

Is it just chrome impacted and why did nobody complain about this?

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