r/codeforces

Problem c

What type of thought arrived you to solution of c like what observation or thinking or which type of questions helped you arrive you to solution
Please help as i am newbie

reddit.com
u/Existential-Compiler — 3 hours ago

When will the rating changes be published?

I cannot stop checking my profile for a rating change.
Gave yesterday's edu div 2 contest. How did it go for you all?

reddit.com
u/TinyChocolate1060 — 12 hours ago

EDU Div2 Problem D prefix sum approach

In yesterday's edu div2, imo spotting LCS was undoubtably easy but where to apply it made the problem way harder...

So this is a question to the ones who successfully solved D: how did you arrive/think about the "Prefix sum % 10" possibility and how did you prove/know it was correct? because in my eyes spotting that is not intuitive at all, even now im not fully convinced on why that approach works as correctly as it does.

reddit.com
u/Available_Buy5643 — 11 hours ago

Educational round 192 discussion

What do you guys think about today's problems? B tripped me up real bad then had an insane comeback and solved till D by 1 hr 20 mins. E seems like something I would do if given 2 more hours😭

reddit.com
u/saddd_soul — 1 day ago

I felt C was hard today

I am a specialist currently and genrerally solve a,b,c in an hour but like today solved a,b in 25 mins but spent 60 mins on C to solve it but the number of solves for C aren't showing its toughness or am I just dumb

reddit.com

How to not feel depressed after a poor contest performance

I feel like crying and feel like I am extremely dumb whenever I perform below my rating level what should I do I feel like quitting sometimes

reddit.com

Why do i feel like today div2 B > C in terms of difficulty

I am kinda new on reddit(and also on cf) and made this account just to post this but i feel like the intuition for B was tougher than C like i got the idea for C in just a few mins but couldnt think of the fact that B required suffix max. Also i feel implementation wise C was also easier but i guess thats just my personal opinion. Pls tell how to think of problems like B like i was thinking greedy but that wasnt working.

reddit.com
u/Ok-Candle-4855 — 1 day ago

Advise for cp mindset

Hi,i solved around 300 questions on cf and mostly between 1200 and 1500,and my current rating is 1100 (max rated 1200),in today's contest i was able to solve only a, and solved b and c within 10 min after the contest,the main problem with me is i have a lot of anxiety when the contest is running and I'm unable to think under pressure,my mindset throughout the contest was to solve the questions as fast as possible,and i think i have the wrong mindset,any advice from seniors about mindset would be very grateful,what should be the mindset in cp and while giving the contest ?

reddit.com
u/Low-Decision-6017 — 1 day ago

EDU DIV 2 B (greedy solution)

The observation i had was just find the smallest partition possible for first 2 by counting number of 1 in 1st half and when it exceeds no of 2s and 3s change boolean variable to true and close the 2nd partition with the same concept of counting nos of 1 and 2. Basically make the 2nd partition as soon as it is possible so that there is atleast 1 element left for 3rd partition.

Code:

void solve(){


    int n;
    cin>>n;
    vector<int> v(n);
    for(auto& x: v) cin>>x;
    int count1=0;
    int count23=0;
    int count12=0;
    int count3=0;
    bool found=false;
    bool found2=false;
    int number;
    for(int i=0;i<n;i++){
        if(!found){
            if(v[i]==2||v[i]==3){
                count23++;
            }else{
                count1++;
                if(count1>count23){
                     found=true;
                     if(v[i+1]==3) i++;
                }else if(count1==count23 ) found=true;
            }
        }else if(!found2){
           
            if(v[i]==3) count3++;
            else{
                count12++;
                if(count12>=count3){
                       found2=true;
                       number=i;
                       break;
                } 
            }
        }
        
        
    }
  
    if(found && found2&& number!=n-1) cout<<"YES\n";
    else cout<<"NO\n";
    
}
reddit.com
u/Dry_Resolution3449 — 22 hours ago

today edu div 2

https://preview.redd.it/kbvs5viu0nbh1.png?width=1471&format=png&auto=webp&s=0f14d618b2521081efa9a82d2c1af9b19234ba74

i wasted so much time on b for no reason i was trying to find better way but endup with the idea from where i started just check if count of 3 current no. and last valid place for 1 found is less than half of size ....
after than c was long question in my opinion it was long in solving part logic was easy tbh but reach there took time for me it was multi step processs idk man
i had find freq. and then find sf summation of it and then check the condition with k for each i
i could have got alot better rank i belive if didnt wasted alot of time and b and because it i had no time for d
i could be pupil
btw its my practice account i am pupil on my account

reddit.com
u/Defiant_Pride_6893 — 1 day ago
▲ 19 r/codeforces+6 crossposts

I built a real time 1v1 coding battle platform with Spring Boot + AWS (2,000+ users)

Built CodeDuels — a real time competitive programming platform with live 1v1 matches using:

  • React + Monaco Editor
  • Java 21 + Spring Boot + WebSockets
  • AWS ECS Fargate, SQS, Redis, RDS
  • Terraform managing 54 AWS resources

Biggest challenge was handling async code execution + real time Codeforces duel tracking without blocking the backend. Solved it using SQS-based microservices and background workers.

Eventually paused the 24/7 AWS deployment because cloud costs got too expensive for a student project, so I migrated everything to on demand Terraform infrastructure.

Demo: https://www.youtube.com/watch?v=nctT-6Y0xJg
GitHub: https://github.com/Abhinav1416/coding-platform

Would love feedback on the architecture and cost optimization ideas.

u/Abhistar14 — 1 day ago

The D problem was quite tough

At first I thought i could solve it and i even wrote the code but realised that to cover all scenarios i would need dp at that point I quit it seemed like 1900 rated what do u guys think????

reddit.com
u/No_Swim8143 — 24 hours ago

Greedy Algorithm Problems are just trust me bro in disguise. I am tired of it.

i have been doing leetcode and cf since 4-5 months. Genuinely i cannot think of Greedy problems . At times I can solve 1300 greedy ones sometimes get stuck at 900 ones too. What even is the greedy bullshit? its no algorithm , theres no theory involved its just TRUST ME BRO .

reddit.com
u/Turbulent_Shine3616 — 1 day ago

rant on today's div 2

took me way too long to do a and b, mainly cause stuff was happening around me, i skipped C and D because I couldnt figure out an approach, might revisit them later

finally, I figured out what to do for E, wrote a code, then spent an hour debugging the code, first for a sigfpe and then for an answer delivery error. I couldn't find the error, so after the contest ended, I gave it to gemini to see what it was.

ONE IF CONDITION ERROR.

The cherry on the top was that my code got accepted, too late though.

This was my code:

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. void solve(){
  4. int l, r, n, x = 0;
  5. cin >> l >> r >> n;
  6. vector<bool> a(32, false), b(32, false), c(32, false);
  7. for(int i = 0; i < 31; i++){
  8. if(r & (1 << i)) a[i] = true;
  9. if(l & (1 << i)) b[i] = true;
  10. //if(a[i] && b[i]) cout << i;
  11. }
  12. int i = 32;
  13. while(i > 0){
  14. i--;
  15. if(a[i]==b[i]) c[i] = a[i];
  16. else{
  17. c[i] = a[i];
  18. break;
  19. }
  20. }
  21. for(int i = 31; i >= 0; i--){
  22. x *= 2;
  23. if(c[i]) x++;
  24. //if(c[i]) cout << i << " ";
  25. }
  26. int y = l;
  27. y = max(1 << (31 - __builtin_clzl(x - 1)), l);
  28. //cout << x << " " << y << endl;
  29. string s1 = "", s2 = "";
  30. while(x > 0){
  31. s1 += (x % 2) ? '1' : '0';
  32. x /= 2;
  33. }
  34. while(y > 0){
  35. s2 += (y % 2) ? '1' : '0';
  36. y /= 2;
  37. }
  38. if (s1.empty()) s1 = "0";
  39. if (s2.empty()) s2 = "0";
  40. reverse(s1.begin(), s1.end());
  41. reverse(s2.begin(), s2.end());
  42. int p = s1.size(), q = s2.size();
  43. for(int i = 0; i < n; i++){
  44. if((s1[i % p] - '0') && (s2[i % q] - '0')) cout << '1';
  45. else cout << '0';
  46. }
  47. cout << "\n";
  48. }
  49. int main() {
  50. // your code goes here
  51. int t;
  52. cin >> t;
  53. while(t--) solve();
  54. }
reddit.com
u/TheBoredBot — 1 day ago

Easiest solution for edu 192,b

Calculate the prefix sum for all indices using logic +1 for 1, -1 for 2 and 3.

Now iterate from backwards and calculate the suffix sum using logic +1 for 1 and 2, -1 for 3,and also maintain a mn,which tells us the min suf sum found from index i+1 to n-1,at any point,pre[i -1]> 0 and suf - mn >=0,we got the answer and we can print yes,if not do it till index 1,if no index satisfies this condition cout no.

Think why the ( suf - mn >= 0) logic works,its just the sum of subarray.from 0 till i - 1 is the part 1,i to mn -1 is second part and mn to n -1 is the third part.

Code

void solution(){

int n;

cin >> n;

vector<int> s(n);

for(int i = 0; i < n; i++) cin >> s[i];

vector<int> pre(n + 1,0);

pre[0] = (s[0] == 1) ? 1 : -1;

for(int i = 1; i < n; i++) pre[i] = pre[i - 1] + ((s[i] == 1) ? 1 : -1);

int sum = 0;

int mn = 1e8;

for(int i = n - 1; i > 0; i--){

sum += ((s[i] == 3) ? -1 : 1);

if(pre[i - 1] >= 0){

if(sum - mn >= 0){

cout<<"YES"<<endl;

return;

}

}

mn = min(mn,sum);

}

cout<<"NO"<<endl;

}

reddit.com
u/Low-Decision-6017 — 1 day ago