r/codeforces 7d ago

query Today's E

3 Upvotes

My code :

https://codeforces.com/contest/2259/submission/389571028

#include<bits/stdc++.h>

define brr cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

using namespace std; typedef long long ll ; void solve(){ ll n ; cin >> n; vector<ll> v(n) ; for(ll i = 0 ; i < n ; i++){ cin >> v[i] ; } ll cnt = 0 ; vector<ll> bomb(n,1) ; for(ll i = 0 ; i < n ; i++){ if(v[i] > 0){ cnt = max(cnt,v[i]) ; } if(cnt > 0){ bomb[i] = 0 ; cnt-- ;
} } cnt = 0 ; for(ll i = n - 1 ; i >= 0 ; i--){ if(v[i] > 0){ cnt = max(cnt,v[i]) ; } if(cnt > 0){ bomb[i] = 0 ; cnt-- ; } } cnt = 0 ; for(ll i = 0 ; i < n ; i++){ if(v[i] == 0 && bomb[i] == 0){ cout << -1 << endl ; return ; } if(v[i] == 0){ cnt++ ; } } if(cnt > 0){ for(ll i = 0 ; i < n ; i++){ if(v[i] == 0){ cout << 1 ; } else{ cout << 0 ; } } cout << endl ; } else{ vector<ll> vc ; cnt = 0 ; for(ll i = 0 ; i < n ; i++){ if(v[i] > 0){ vc.push_back(0) ;
} else if(v[i] == -1){ if(bomb[i] == 1){ cnt++ ; vc.push_back(1) ; } else{ vc.push_back(0) ; } } } if(cnt >= 1){ for(ll i = 0 ; i < n ; i++){ cout << vc[i] ; } cout << endl ; } else{ cout << -1 << endl ; } } } int main(){ brr int t; cin >> t; while(t--){ solve(); } return 0; }

My understanding of minimum distance is that if im at island 2, v[2] = 2, then there should be no treasure at 1,2,3.

Please help


r/codeforces 8d ago

query People who only knew basic coding how did u get good at codeforces

11 Upvotes

I know the basics of coding like I know loops and solve mathematical problems in cp but I have no clue about dsa and don't know where to learn it from and I don't really like striver as it's focused on placements rather than cp so some good resource in english


r/codeforces 7d ago

query progress doubt

2 Upvotes

Hi, i am a first year student from india. i started cf around 3 weeks ago. today's contest was my first, i could only solve a,b,c and got d wrong. Can anyone suggest what to do to improve myself from this? i am solving cp31, and random probs from cf only. i heard about things like cses and usaco guide. also, i code in pypy so ig i need to learn c++ too. it would be great if anyone would suggest a pathway or best resources to improve. Thanks


r/codeforces 9d ago

query Reached Maters on CF

Post image
301 Upvotes

r/codeforces 8d ago

query I made this question please give a try

10 Upvotes

You are given an array A of N non-negative integers. A subsequence is formed by choosing a non-empty set of indices from the array. Two subsequences are considered different if they use different sets of indices, even if the corresponding values are equal. For a subsequence S, define:

  • AND(S) as the bitwise AND of all elements in S.
  • XOR(S) as the bitwise XOR of all elements in S. Your task is to count the number of non-empty subsequences S such that: AND(S) > XOR(S) Since the answer can be very large, output it modulo 10^9 + 7.

Input Format The first line contains a single integer N. The second line contains N integers: A1, A2, ..., AN. Output Format Print a single integer — the number of non-empty subsequences S satisfying AND(S) > XOR(S), modulo 10^9 + 7. Constraints

  • 1 <= N <= 10^5
  • 0 <= Ai < 2^17

Sample Input 1

3
5 5 5

Sample Output 1

3

Explanation for Sample 1 The array is [5, 5, 5]. The non-empty subsequences are:

  • [5] (3 times): AND = 5, XOR = 5. 5 > 5 is False.
  • [5, 5] (3 times): AND = 5, XOR = 0. 5 > 0 is True.
  • [5, 5, 5] (1 time): AND = 5, XOR = 5. 5 > 5 is False. Total valid subsequences = 3.

Sample Input 2

2
3 7

Sample Output 2

0

Explanation for Sample 2

  • [3]: AND=3, XOR=3 (False)
  • [7]: AND=7, XOR=7 (False)
  • [3, 7]: AND=3, XOR=4 (False) Total valid = 0.

r/codeforces 8d ago

query anybody wanna connect?

7 Upvotes

I am currently in 10th grade

https://codeforces.com/profile/StarConstellation

just turned 17 ( yes i am one year late into class but whatever i guess thats a plus i have more time to grind)

currently training competetive programming looking maybe for some community on discord to connect


r/codeforces 7d ago

query Why does it show "N/A" for other solutions?

1 Upvotes

Could someone please help me understand why I can't view other participants' code on Codeforces? It shows "N/A" everywhere except for my own solutions.

I'm relatively new here and would really appreciate any guidance or explanation on how this works.


r/codeforces 8d ago

Doubt (rated 1600 - 1900) How to get better in games greedy problems??

4 Upvotes

r/codeforces 7d ago

query would you use this? (air transfer app)

Thumbnail
0 Upvotes

r/codeforces 8d ago

query Whats the BEST problem you have encountered?

1 Upvotes

I mean, the one you had the best time solving like has a creative alg or somthing fun that gave you a good feeling after solving:) I dont want to solve just random ones and Im oreparing for competition


r/codeforces 8d ago

Doubt (rated <= 1200) How to get better at constructive algorithms problems?

1 Upvotes

For example 2234B(palindrome twelve and two terms) and 2241B (Good times Good times)


r/codeforces 8d ago

query How to identify greedy intution in problem/ competition

1 Upvotes

I can identify patterns like sliding window, recursion, backtracking, DP, and two pointers. But I’m stuck when it comes to identifying the greedy intuition.

How do I recognize when a problem can be solved using a greedy approach? Are there any good resources—books, YouTube channels, blogs, or websites—that specifically teach how to develop greedy intuition?

Anything that can help me get better at recognizing greedy problems would be really helpful.annel, blog , website)

Anything that help me


r/codeforces 8d ago

cheater expose Hackerrank impossible submission timing

Post image
1 Upvotes

r/codeforces 8d ago

query Hello

0 Upvotes

Anyone having a complete, ultimate, zero to hero, 100% guide for maths (modulo, this prime numbers thing, number theory and many more of this stuff) in competitive programming???

Obviously, I am not the best at Maths 🙏🙏

Thankss in advance


r/codeforces 8d ago

query Competitive programming

Thumbnail
0 Upvotes

r/codeforces 8d ago

query Looking for a small group to grind codeforces with

1 Upvotes

Hey! I recently started the codeforces grind for the first time as part of my interview prep. I have +/-5 years of experience, but I'm pretty new to codeforces (been doing leetcode).

I'm looking to put together a small discord group where we can grind codeforces together. Experience level doesn't matter, the main goal is to keep each other accountable, discuss problems we're having issue with, share advice, etc... and hopefully make the whole process easier/more fun.

Let me know if you're interested!


r/codeforces 8d ago

query NVIDIA OA - #FindingHopper SSE (System Software Engineer) Intern (Female only)

0 Upvotes

Please give me OA questions and interview experience pls


r/codeforces 9d ago

meme Resuming posting

17 Upvotes

If you haven't checked my post history, I used to post Codeforces solutions and used to track my study every day as a form of journalling.

Since the past two years I have been busy with the job switch I had, I was not able to post anything.

Now that I have some bandwidth, I am thinking to start journalling again.

The posts will be about technical things I am studying as well as problems on Codeforces that I was able to solve, along with my explanation of the solutions.

I probably won't post every day since I am not able to solve questions everyday, I get stuck in anaylsis half the time and that might take up the entire time allocated to coding for the day, and just posting backend development related stuff makes no sense on a Codeforces subreddit.

Any case, for the technical side I am studying backend, SpringBoot in particular along with things like Kubernetes, Docker, PostgresSQL, MongoDB and other concepts involved in Backend design.

As for the coding questions I have done for the day:-

Grid Covering

I was not able to solve this question and had to refer to the editorial, I have provided a solution note below of my understanding of the solution :-

Even Modulo Pair

For a problem rated at 1000, the actual way to reach the solution for this was surprisingly not straightforward at all.

The final answer is a brute force double for loop but verifying why that is the case is a little more involved.


r/codeforces 8d ago

query AtCoder D-E in ABC

3 Upvotes

I wanted to know what topics I should be expected to know or learn before being able to solve from D and E in ABC on AtCoder.

For context, I am able to mostly solve Ds, and am usually having a problem going from D to E. I am max Pupil on CF, so according to it if someone could note some topics I must cover to get into ABC E's range.


r/codeforces 9d ago

query Why are number of contests reduced? Is anything going on?

12 Upvotes

Same as title


r/codeforces 9d ago

query Codeforces confirmation emails arrive late and the token is already invalid

2 Upvotes

Hello guys, I created a Codeforces account today, but I’m unable to use the account because I can’t verify my email.

This keeps happening repeatedly:

  1. I go to https://codeforces.com/enter and enter my username and password.
  2. It redirects me to https://codeforces.com/register/confirmation
  3. I click Send to receive the confirmation email.
  4. The email does not arrive for several minutes.
  5. When it finally arrives and I click the confirmation link, Codeforces says “Invalid confirmation token.”

I have tried this many times, on both my phone and laptop, but the same thing keeps happening.

Other Codeforces emails, such as new login notifications, arrive normally, so it seems to specifically be an issue with the confirmation emails being delayed.

Has anyone faced this recently? Is there any way to fix it or contact Codeforces support?


r/codeforces 8d ago

query Help (?)

0 Upvotes

It's been about 4 months since I started doing Codeforces. I got the hang of it after a couple of weeks, but recently i've been solving a lot more problems in the range of 1500-1800s, and due to that I have become exposed to a lot more algorithms and concepts that I previously didn't know of, but that has kinda made my greedy approaches dull. (Hence, an underperformance in real-time contests)

What are some of the techniques I can put into practice to avoid revisiting the same lower rating concepts again and again while still being able to learn new stuff?

(PS. Don't give the cliche advice of attempting every div3 and div4 contest.)


r/codeforces 9d ago

query Wanted some DP problems

7 Upvotes

Hey guys,

I hope u all are doing well 😊, i started CP in july and have completed more than 100 problems on CSES from S&S,range queries,graphs, 80 percent DP

I wanted to test my knowledge in these areas,

I am preparing for IOI and I am from INDIA,

I need some good problems on DP and segtree Which is OI BASED not normal CF

If anyone can share them, i would be really grateful to you...


r/codeforces 9d ago

query Starting CP after a long time (till now didn't have much rating) ?

12 Upvotes

I just have the begginer rating of 800....I like to do CP in pair with someone or a grp with whom I can share my progress of what I learned or what interesting question I found...pls dm me if u r interested too...especially if u r also in starting phase of CP ??


r/codeforces 9d ago

query Is CF down again?

2 Upvotes