PR_0202's blog

By PR_0202, 4 months ago, In English

Hello everybody!

I am a Computer Science undergraduate currently in my 2nd year and want to develop some projects. I know other developments like android dev or web dev, but I want to do a project related to cp in which I can apply some algorithms.

I searched on the internet but found projects like sudoku solver and pathfinder that are too common nowadays, and It would be great if you can share your ideas and previous projects related to CP... I would be too grateful to you!


Read more »

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

By PR_0202, 9 months ago, In English

Many times we are stuck in a problem and don't know the edge case in which the programme fails, specially during long challenges or monthly challenges we think our solution is correct but it gives WA on submition. So, I'm sharing my idea to stress test your code with a bruteforce or an unoptimized solution without using bash.

So, basically what you have to do is first write a brute force solution and put it in the "Solve" function and put the optimized ones in the second one. change the function and return value according to the question also if you want then make the test generating while loop infinite also adjust the array size according to the constraints of your bruteforce solution.

I would recommend you to use Code-blocks or VS Code for this purpose.

Code begins:

#include <bits/stdc++.h>

using namespace std;

const int N = 100005;
const int MOD = 1e9 + 7;

#define show(arr) { for (auto x: arr) cout << x << " "; cout << '\n'; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int randNo(int lower_limit, int upper_limit){
	return lower_limit + rng()%(upper_limit-lower_limit);

int solve(int arr[], int n) {
	int ans = 0 ;
	//write here your optimed code with low complexity
	return ans;

int solve2(int arr[], int n) {
	int ans = 0 ;
	//write here your brute force solution
	return ans;

int32_t main() {
	int testCases = 1000000;
		//generating n
		int n = randNo(1,100);
		//To generate a random array
		int a[n];
		for(int i=0;i<n;i++) a[i] = randNo(1,N);
		int naive_ans = solve2(a,n);
		int optimised_ans = solve(a,n);
		if(naive_ans == optimised_ans) cout << "YES\n";
			cout << "NO\n";
			cout << n << '\n';
			cout << naive_ans << '\n';
			cout << optimised_ans << '\n';

Any suggestion/Edits or questions are welcomed.! :) If you are downvoting please comment the reason so that I can improve..

Edit 1: Don't use rand(): a guide to random number generators in C++ Please read this once to generate random numbers efficiently thanks GLAYS .

Edit 2: Updated rand() with mt19937 rng().

Read more »

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

By PR_0202, 12 months ago, In English


From the previous 5 months I gave about 40+ contest and I am still stucked at Expert everytime I hit 1800+ rating it falls down again and again....

Please suggest me some strategy to become a Candidate Master on CF.

Thanks in advance...

UPD 1: Finally after 7 weeks of this blog I became CM :)

many of my friends were asking for suggestion. so, here are the few of them.!

  1. Errichto, Aman Dhattarwal and Love Babbar (in hindi) playlist if you want to step into CP or you're a beginner.
  2. If you want to be rated X, then you must be able to solve problem with rating X+200. And try to solve every problem within a short time as you're in competing.
  3. Whenever giving a contest, don't care about falling of your rating, your aim should be to solve as many problems as possible, it really helped me to improve my performance in the contest.
  4. Up-solving (Atleast problems till 2000 rating).
  5. Try finding weak areas and start solving those problems.
  6. Try to make friends who are having rating +(100-200) of your current rating and who gives contests frequently.
  7. Most important Don't Give Up.

UPD 2: After continuous grinding of about 7 months of last update I finally became Orange :)

Read more »

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

By PR_0202, history, 14 months ago, In English

I am confused about how to get sum from a node y to its ancestor x using a segment tree. there is query of 10^5 order consists of update and find sum of the nodes between them.!

Read more »

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