Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

zeyd1234's blog

By zeyd1234, 6 weeks ago, In English
  • Vote: I like it
  • +36
  • Vote: I do not like it

By zeyd1234, 3 months ago, In English

Hi Codeforces and problem setters!

While preparing a problem in Polygon, I once again ran into a classic headache when validating tests with incorrect/suboptimal solutions (e.g., greedy approaches, wrong heuristics, or $$$O(NK)$$$ DP instead of $$$O(N \log C)$$$).

The Problem

Imagine a standard situation: a problem setter writes a flawed solution to make sure the test suite catches it.

Here is what happens in practice:

  1. On small tests at the beginning of the testset, the code outputs an incorrect result and gets Wrong Answer.
  2. On large tests ($$$N = 10^5$$$), the exact same code hangs in an unoptimized loop and gets Time Limit Exceeded before it even gets a chance to output a wrong answer.

Question: Which tag should we assign to this solution in Polygon?

  • WRONG_ANSWER — Fails with PackageException, because on large tests the code gets TLE instead of WA.
  • TIME_LIMIT_EXCEEDED — Fails with PackageException, because on small tests the code gets WA instead of TLE.
  • TL_OR_OK / WA_OR_OK — Not applicable, because the solution should not pass the full testset anyway.
  • FAILED — Fails with PackageException, because Polygon expects a runtime or logic error, but the process gets killed by TLE on larger tests.

PackageException in Polygon

Current Workarounds (And Why They Suck)

Right now, problem setters have to invent ugly crutches just to satisfy Polygon's strict tag system:

  1. Adding artificial cutoffs like if (n > 1000) return 0; so the greedy code terminates instantly and gets a clean WA without timing out.
  2. Manually crafting micro counter-tests and shuffling them to the very top of the test list.
  3. Simply deleting these flawed solutions from the repository, which directly lowers the quality of testsuite validation.

We spend time micro-optimizing intentionally wrong solutions just to appease the invocation checker, which feels counterproductive.

Current variants

Proposed Solution

Add a WA or TLE tag (or a broader INCORRECT / ANY_ERROR tag) to Polygon.

Proposed Tag Logic:

A solution passes verification if it fails on the testset with either WA, TLE, ML, or RE, as long as it is rejected by the testsuite and does not get an overall OK.

This small addition would save problem setters a ton of time and make task development in Polygon much smoother.

What do you think?

UPDATE: Turns out I was just sleep-deprived. The Incorrect tag does exactly what I needed. Thanks for reading!

I'm dumb

Full text and comments »

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

By zeyd1234, 3 months ago, translation, In English

Is it just me, or have recent Div. 2 / Div. 3 contests become almost entirely constructive algorithms and ad-hoc math?

Look at the recent B, C, and D problems — virtually zero standard DP, graphs, or classic data structures. It’s usually just "stare at the statement for 20 minutes, spot the weird mathematical trick, write 5 lines of code". If you spot the trick instantly, you get a massive +delta. If not, you get stuck on Problem B for an hour, even if you know advanced CS inside out.

I get why problem setters are doing this. It stops people from mindlessly pasting Segment Tree templates, it lowers the barrier for beginners, and it makes life harder for ChatGPT/Claude cheaters.

But the variance on these ad-hoc tasks is insane. Sometimes it feels like CF is losing its algorithmic soul compared to platforms like AtCoder, which still feel much cleaner and more structure-oriented.

Not saying constructive problems are inherently bad, but the current balance feels a bit off. Would you guys prefer a return to more standard DS/DP in Div. 2/3, or do you actually enjoy this meta?

Full text and comments »

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

By zeyd1234, 3 months ago, In English

Honestly, China getting 4 golds every single IOI is just insane at this point. Half the time the fight for #1 individual spot is just between teammates!

People meme about secret routines, but looking at their actual setup, it totally makes sense:

Internal competition is brutal:

Out of tens of thousands of participants, only 50 make the national team gathering (集训队), and then just 4 go to IOI. There are easily 20+ Chinese coders every year who didn't make the top 4 but would easily get a high gold if they represented almost any other country!

Gaokao bypass:

Top 50 in NOI means automatic admission to Tsinghua (like Yao Class) or PKU, completely skipping the Gaokao nightmare. That’s a life-changing reward, so kids start grinding full-time from middle school.

Actual infrastructure:

Places like Changjun or Hangzhou No. 2 are practically CP academies with full-time coaches, and platforms like Luogu make high-quality problems and editorials super accessible.

A few questions for the Chinese CPers here:

  • What does the daily routine actually look like when preparing for NOI / CTS? How many hours a day are spent solving problems vs theory?

  • Do you feel the 4-person country cap hides just how deep the talent pool actually is?

Would love to hear your thoughts or stories from the CTS grind!

Full text and comments »

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

By zeyd1234, 3 months ago, In English

Hello Codeforces.

Thank you to everyone who participated in Amateur Round 2! I hope you enjoyed the problemset and found the tasks interesting!

Below you will find the winners, tutorial and analysis for all the problems. If you have any questions, spot any errors, or have alternative approaches, feel free to discuss them in the comments!

Congratulations to the top 10 winners!

Rules
  1. Mitpro
  2. AR14505
  3. manhhomienbienthuy
  4. Juan_Alejandro
  5. Vansh_Vala
  6. unorz
  7. iamsenku
  8. Daksh_soni45
  9. Radh73
  10. Rynical

A special shoutout to the top — 9 participants who managed to solve all the problems — absolute legends!

A. Alice's Code Lock

Hint
Tutorial
Code
Rate the problem!

B. Bob's Unique Coins

Hint
Tutorial
Code
Rate the problem!

C1. Bob and Festive Garland (Easy Version)

Hint
Tutorial
Code
Rate the problem!

C2. Bob and Festive Garland (Hard Version)

Hint
Tutorial
Code
Rate the problem!

D. Saving Bob

Hint
Tutorial
Code
Rate the problem!

E. Smart Elevator

Hint
Tutorial
Code
Rate the problem!

Full text and comments »

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

By zeyd1234, 8 months ago, translation, In English

Hi Codeforces.

Today I came across a legendary problem: 896E - Welcome home, Chtholly. It’s rated $$$3100$$$ and is known for being a nightmare for data structure enthusiasts. The tags say "DSU" and "Data Structures," and the intended solutions involve complex Sqrt-decomposition or Segment Tree Beats.

But as my future handle suggests -- $$$SegTreeIsAMyth$$$. I decided to see if a simple $$$O(N \cdot M)$$$ brute force could pass.

To my surprise, it didn't just pass: it $$$crushed$$$ the tests in $$$1750ms$$$ (with a 3s limit)!

Screenshot:

The Code

The core of my solution is just a simple loop. No complex trees, no heavy pointers.

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define debug cout << "Debug\n"
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

/*
      ---===ASCII help===---
     '0' -> 48     '9' -> 57
     'A' -> 65     'Z' -> 90
     'a' -> 97     'z' -> 122
*/

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n, m; cin >> n >> m;
    int arr[n];
    for (int i = 0; i < n; ++i) cin >> arr[i];
    while (m--) {
        int t, l, r, x; cin >> t >> l >> r >> x;
        --l; --r;
        if (t == 1) {
            for (int i = l; i <= r; ++i) {
                if (arr[i] > x) arr[i] -= x;
            }
        }
        else {
            ll ans = 0;
            for (int i = l; i <= r; ++i) {
                if (arr[i] == x) ++ans;
            }
            cout << ans << '\n';
        }
    }
}

Why did it pass?

Many of you might think $$$10^{10}$$$ operations shouldn't pass in 3 seconds. Here is why it did:

  • GCC 14 & AVX2: The #pragma GCC target("avx2") allows the compiler to use SIMD instructions. It processes multiple integers in a single CPU cycle.

  • Loop Unrolling: #pragma GCC optimize("unroll-loops") reduces the overhead of the loop control.

  • Cache Locality: A simple array traversal is the most cache-friendly operation possible. While a Segment Tree jumps around in memory causing cache misses, the CPU prefetcher loves this linear scan.

  • Modern Judges: Codeforces' upgraded hardware is incredibly fast at executing vectorized code.

Conclusion

Next time you see a 3100-rated problem, don't be afraid. Sometimes, the "dumb" solution with the right pragmas is more powerful than the most sophisticated data structure.

Is Segment Tree actually a myth? My submission says yes.

UPD: Bruh, -16. Maybe SegTree lovers hates me.

UPD 2: My contribution is dropping faster than the array values in the problem. Mission accomplished: SegTree lovers are officially summoned!

Full text and comments »

  • Vote: I like it
  • -47
  • Vote: I do not like it

By zeyd1234, 10 months ago, translation, In English

Hello again. Thank you for participating. I hope that you liked the problems. Sorry for the mistakes in constraints and statement. In other rounds, i will check all tasks twice, to don't allow that mistakes. There is an Editorial:

A — Petya and Car Counting

Solution
Implementation

B1 — Armstrong Numbers Count

Solution
Implementation

B2 — Armstrong Numbers Count(Harder Version)

Solution
Implementation

C — Active Users in Chat

Solution
Implementation

Full text and comments »

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

By zeyd1234, 10 months ago, In English

Hello everyone. I invite you to the Amateur Round 1 (Div. 4), which already started in 07.01.2026 and ends in 15.01.2026.

You will be given 4 problems to solve. One problem will be divided into subtasks. The round will be in ICPC style.

The problems authored by zeyd1234.

I want to say "Thank you" to:

  • You for participating.

Note:

If you are using Python, use sys.stdin.readline() instead of input() to prevent EOFError.

UPD: Editorial is out.

UPD2: Congratulations to the top — 10 winners:

Rules
  1. krishnsai324
  2. goririn
  3. jowelo
  4. C99_x
  5. Light_Bender
  6. Ajay967
  7. mathc
  8. Senpai_
  9. TruthSeekerGT
  10. UkashaUKPower

And congratulations to top — 15 by official standing:

  1. PhirainEX
  2. ink65536
  3. reirugan
  4. krishnsai324
  5. potatoArmy
  6. Mitpro
  7. Furioso_Slient
  8. salemi1
  9. goririn
  10. Jim_X
  11. jowelo
  12. C99_x
  13. fatespeaker
  14. OAY71011
  15. Light_Bender

And this is a top — 10 by only WA penalty count:

  1. reirugan
  2. goririn
  3. OAY71011
  4. Zaid_804
  5. KaiLearningCP
  6. MisterGir
  7. cy171
  8. wtf.rjdp1
  9. sahaun
  10. raafael

Full text and comments »

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