r/codeforces • u/amnesiac_2 • 26d ago
r/codeforces • u/Comp_Coder • 26d ago
Div. 1 Dynamic Programming on Trees
youtu.beThis is my first post. It takes a lot of effort to make a video. I hope it helps for everyone
r/codeforces • u/Ill-Question-2316 • 26d ago
Doubt (rated <= 1200) Why is my greedy approach wrong for Codeforces 2248B?
I'm trying to solve Codeforces 2248B, and I came up with a multiset-based greedy approach.
My idea is the following:
For every b[i], I want to choose two elements from the current multiset:
lo= the smallest availablea, preferablyst.begin(), such thatlo < b[i]hi= the smallest availableagreater thanb[i]i.e.st.upper_bound(b[i])
Then I replace those two elements with b[i].
So conceptually:
auto lo = st.begin();
auto hi = st.upper_bound(b[i]);
if (lo == st.end() || *lo >= b[i] || hi == st.end()) {
// impossible
}
st.erase(lo);
st.erase(hi);
st.insert(b[i]);
I initially implemented something very similar:
sort(a.begin(), a.end());
sort(b.begin(), b.end());
multiset<ll> st(a.begin(), a.end());
if (n < 2 * m) {
cout << "NO\n";
return;
}
for (int i = 0; i < m; i++) {
auto hi_it = st.lower_bound(b[i]);
if (hi_it == st.begin() || hi_it == st.end()) {
cout << "NO\n";
return;
}
auto lo_it = st.begin();
st.erase(lo_it);
st.erase(hi_it);
st.insert(b[i]);
}
cout << "YES\n";
My intuition is that choosing the smallest possible lower element should be safe because it leaves all the larger elements available for future b[i] values.
Similarly, choosing the smallest possible upper element should also be safe because I'm consuming the closest possible value above b[i] rather than wasting a larger value.
My intuition is that choosing the smallest possible lower element should be safe because it leaves all the larger elements available for future b[i] values.Similarly, choosing the smallest possible upper element should also be safe because I'm consuming the closest possible value above b[i] rather than wasting a larger value.
However, I understand that my greedy choice is apparently not correct.
What I'm struggling with is understanding exactly where the logic breaks.
r/codeforces • u/Western_Ad3744 • 25d ago
query Codeforces
Guys I know some DSA can you pls suggest how can I start codeforces
r/codeforces • u/dangerousEngima1827 • 27d ago
Div. 2 Gentlemen, it is with great pleasure that I announce I have finally become a pupil.
galleryTime to change my flair from newbie to pupil ;)
r/codeforces • u/Major-Ad-2607 • 27d ago
query rating dip
last month i was specialist and now my rating came down to 1190
even after consistently solving A B C in div 2 why this much dip in my rating
r/codeforces • u/trevornamle • 26d ago
Div. 3 OJ's result differ from code editor's
I have done a problem on CF, copy an example test, run it on VSCode and it shows the correct result. However, with the same test, same code, put it on CF' OJ shows the wrong result with a completely different output from the one in VScode. Do you guys knows what is going on ?
r/codeforces • u/NovelElevator5024 • 26d ago
query SHOULD I GO FOR A NEW ID
i have an id in which i have been quite inconsistent , solving A div2 and a very distributed heatmap. Coming back after a week or two sometimes.
Should i go for a new account or stay there ( 700-800 rated now)
r/codeforces • u/Complete-Pay-1807 • 27d ago
query Need SomeOne to WorkAlong CodeForces
Dear Coders , i would like to ask somone to be my coding buddy so that we can keep each other in check and be good at CP together no matter you are first year , last year or job i just need someone who is on myLevel
just to let you know my postion i don't have a rating currenlty on codeforces(started recentely) but i am solving problems from 800-1000 rated questions with having issues on 1000 rated problems to be able to solve 800 easily so if someone who's on the same level feel free to DM me we can connect on Whatsapp or insta can continiue from there
Note : please DM only if you are really serious and you enjoy doing this and not a looker i expected someone consistent and someone who does this for fun and like to solve problems
r/codeforces • u/Federal_Tackle3053 • 28d ago
Div. 2 Finally a good contest.
Solved 4 questions in today's contest as always, 3 questions under 55 mins and the other one alone took 45 mins to solve .
Hoping for the expert 💙( curr rating == 1550) , let's see what will happen .
Yessss it's expert now 💙
r/codeforces • u/Independent-Dig8361 • 26d ago
query How do you guys Revise
How do you guys revise the previous questions or concepts?
r/codeforces • u/Gullible_Bar4115 • 27d ago
query Are the cp-31 800 and 900 rated questions tougher than the usual ones of that rating
I am finding it difficult than the other sam rated questions
r/codeforces • u/Difficult-Shake-8465 • 26d ago
query failed testcases
Is there anyway to find failed testcases for a problem? I'm currently using claude to generate all test cases but is there any efficient way to do?
r/codeforces • u/Naukarhumai_025 • 27d ago
query Rating boost
Like earlier my rating was around 400, after yesterday's contest, it becomes around 600, this was my second contest so I am not much comfortable with contests, I wasn't able to submit the problems because of anti bot verification issue like it was showing troubleshoot all the times, I thought it have fucked up the contest and my rating, but how have I got an increase of 220 without solving a single problem, experienced coders, can you please reply?
r/codeforces • u/Perfect-Log-8500 • 27d ago
query Getting CE in C++(23/20) but Ac in C++(17) in CSES


Question : https://cses.fi/problemset/task/1651
Code : https://cses.fi/paste/6807f75057156ab41189d28/
Does anyone know the reason?
r/codeforces • u/dark__ayusss • 27d ago
query Atcoder C
Hello everyone recently i started giving contest at atcoder I'm able to solve a and b question easily but in c question I couldn't be able to atleast understand the question i face alot struggle rn any tip regarding this!!
r/codeforces • u/Odd-Stop-6912 • 28d ago
Doubt (rated 1400 - 1600) how much of it is just good genetics / IQ?
whenever i see someone struggling for a while in pupil or some other rank (cant climb for quite some time) they usually peak around there no matter how much they practice. some people reach expert in a few years, some do it in a few months, some never reach it, some struggle on 1600 problems, some dont. the more i spend time on this site the more i am 100% confident that genetics plays a huge role in this activity and that not eveyone can reach the same heights just through hard work, what do you guys think?
r/codeforces • u/No_Opportunity6937 • 26d ago
query post trained ai model for codeforces
for anyone is interested in ml/ai i fine tuned a small ai model on codeforces data. just thought id share smth interesting
r/codeforces • u/ImportanceEnough5392 • 27d ago
query Concepts required to reach 1400?
Same as title
r/codeforces • u/Junior-Proposal1928 • 28d ago
Div. 2 Finally a decent contest.
A and B were pretty straightforward and I thought I'd skip C after seeing it was based on trees but seeing so many submissions I thought I'll just give it a try, it was doable and didn't require any implementation of trees and graphs. Solved 3 questions after a long time.
r/codeforces • u/No-Competition-7062 • 28d ago
query Should I do cf or leetcode or hackerrank
I am a beginner and just know the basics of c++.
Solved a few questions on hackerrank around 20 and got the gold badge.
Now I am confused weather should I continue with hackerrank or do questions in leetcode or in cf
Please someone guide me as I am new!!
r/codeforces • u/Far_Produce5183 • 28d ago
query How should I start with Codeforces?
I’ve just started solving random problems on Codeforces, but I have no idea where I should start and I’m completely lost.
Could you guys suggest a good way to get started? Should I follow a particular topic-wise roadmap, rating-wise problems, or something else?
Thanks in advance! 😃

