Dear Codeforces Team,
Thank you for notifying me about the code similarity issue. I'd like to respectfully explain the situation regarding my submissions for problems.
Contest 2143 D1
- Problem Constraints Lead to Natural Solutions:
This is an easy version with n ≤ 300, which naturally suggests using dynamic programming with O(n^3) complexity
The state definition
dp[l][r]is a common approach for subsequence counting problems with ordering constraints
- Standard Coding Patterns:
- The modulo arithmetic handling (
+= cur; if (>= MOD) -= MOD) is a well-known optimization technique - The
dp/ndpswap pattern is standard in iterative DP implementations to save memory - The triple nested loop structure is typical for subsequence DP problems
- My Problem-Solving Process:
- I approached this by considering how to track the "color constraints" through the largest red and blue elements seen so far
- The state
(l, r)represents the maximum values in the two color groups, which is a logical way to ensure the coloring condition
Contest 2143 D2
- Evidence from the author
So now we only have O(n^2) "state updates", but each takes linear time, keeping us at O(n^3). However, the transitions are now simple enough to apply a data structure on them, such as a fenwick tree.This sentence come from the editorial, the author also said that the solution should be fenwick tree, so it is Straightforward to it.
- Beyond compare with other similar codes
lukagvritishvili/339140741 vs Terrorb1ade/339121844. The result of beyond compare is below:

they are totally different.
-tyler_durden/339140213 vs Terrorb1ade/339121844:
a lot of details are different.
Reduction to absurdity
Assuming that I plagiarize code from other places, let's say, chatgpt. More exactly, contest 2147 G, which is a tough one, but a lot of constants solved it, this is the ac code generated by chatgpt:
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
const int MAXA = 1000000;
const int64 MOD = 998244353;
// ----- SPF (最小素因数) を線形ふるいで作る -----
vector<int> spf(MAXA + 1);
vector<int> primes_list;
void build_spf() {
spf[1] = 1;
for (int i = 2; i <= MAXA; ++i) {
if (spf[i] == 0) {
spf[i] = i;
primes_list.push_back(i);
}
for (int p : primes_list) {
long long ip = 1LL * i * p;
if (p > spf[i] || ip > MAXA) break;
spf[ip] = p;
}
}
}
vector<pair<int,int>> factorize_int(int n) {
vector<pair<int,int>> res;
while (n > 1) {
int p = spf[n];
int c = 0;
while (n % p == 0) { n /= p; ++c; }
res.emplace_back(p, c);
}
return res;
}
int64 mod_pow(int64 a, long long e) {
int64 r = 1 % MOD;
a %= MOD;
while (e > 0) {
if (e & 1) r = (__int128)r * a % MOD;
a = (__int128)a * a % MOD;
e >>= 1;
}
return r;
}
int64 mod_inv(int64 a) { return mod_pow(a, MOD - 2); }
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
build_spf();
int T;
if (!(cin >> T)) return 0;
while (T--) {
int x, y, z;
cin >> x >> y >> z;
// m = x*y*z (mod MOD)
int64 m_mod = x % MOD;
m_mod = ( (__int128)m_mod * (y % MOD) ) % MOD;
m_mod = ( (__int128)m_mod * (z % MOD) ) % MOD;
// m の異なる素因数集合 {p}
// ついでに "q divides m?" 判定用に set かソート済みベクタ
vector<pair<int,int>> fx = factorize_int(x);
vector<pair<int,int>> fy = factorize_int(y);
vector<pair<int,int>> fz = factorize_int(z);
// p -> dummy exponent(合算しても区別なく「存在」判定に使う)
unordered_map<int,int> pExp; pExp.reserve(16);
auto add_pf = [&](const vector<pair<int,int>>& pf){
for (auto [p,c] : pf) pExp[p] += c;
};
add_pf(fx); add_pf(fy); add_pf(fz);
// {p} をベクタに
vector<int> pList;
pList.reserve(pExp.size());
for (auto &kv : pExp) pList.push_back(kv.first);
sort(pList.begin(), pList.end());
// E_q = sum_{p|m} v_q(p-1)
unordered_map<int,int> Eq; Eq.reserve(32);
for (int p : pList) {
int t = p - 1;
if (t <= 1) continue;
auto pf = factorize_int(t);
for (auto [q, e] : pf) {
Eq[q] += e;
}
}
// ans = (xyz)^(-1) * Π_{q not| m} ((q^{E_q}+q-1)/q)
int64 ans = mod_inv(m_mod);
auto divides_m = [&](int q)->bool{
return binary_search(pList.begin(), pList.end(), q);
};
for (auto &kv : Eq) {
int q = kv.first;
int e = kv.second;
if (e == 0) continue;
if (divides_m(q)) {
// q | m のとき寄与は 1(= 何もしない)
continue;
}
int64 q_mod = q % MOD;
int64 term_num = (mod_pow(q_mod, e) + (q_mod + MOD - 1)) % MOD; // q^e + q - 1
int64 term = (__int128)term_num * mod_inv(q_mod) % MOD; // (q^e + q - 1)/q
ans = (__int128)ans * term % MOD;
}
cout << ans << '\n';
}
return 0;
}
the code come from physics0523 shared in entry 146629.
Plz don't focus on what I gained, look at what I lost, I lost 252 rating in global round 29, think about it, why did not I use chatgpt to generate the ac code?
Conclusion
I understand that code similarity detection is important for maintaining contest integrity, and I appreciate your efforts in this regard.
Thank you for your understanding and consideration.




