CantLoseNow's blog

By CantLoseNow, history, 3 months ago, In English

can someone explain in a easier way how to solve this problem . I cant understand the editorial. specifically the part where it says "ai iterations in i-th step is equal to doing ai mod (n - i) iterations (0-based numbering). That is less than n". Please help.

Full text and comments »

 
 
 
 
  • Vote: I like it
  • -2
  • Vote: I do not like it

By CantLoseNow, history, 3 months ago, In English
 
 
 
 
  • Vote: I like it
  • +3
  • Vote: I do not like it

By CantLoseNow, history, 3 months ago, In English

so i want to do cp but i dont have friends to do with them. i heard your productivity grows if you do cp with friends.

Full text and comments »

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

By CantLoseNow, history, 3 months ago, In English

Solving random problems from codeforces problem set makes me feel that i am just doing stuffs without any goal. It contains many questions so you cant have a goal to complete the whole set. So i was wasting a lot of my time looking for codeforces blogs that tells about a good problem set. But these sets are either old or dont have enough questions. i would like to know your opinion on these sets and suggest me the best set you think is available right now.

The sets i found were: 1) A2oj ladders 2) CSES Problem Set — https://cses.fi/problemset 3) Mostafa Saad Sheet — https://goo.gl/unDETI 4) Kartik's Specialist Sheet — https://docs.google.com/document/d/1CcayDX2Gg4r2sxFhrZCPPcIwNzhKXfYa1wSuvr3OMzU/edit 5) kenkooo training bootcamp sheets — https://kenkoooo.com/atcoder#/training

please tell if you follow any different sheet. and why do you like it?

Full text and comments »

 
 
 
 
  • Vote: I like it
  • -1
  • Vote: I do not like it

By CantLoseNow, history, 3 months ago, In English

see this imageand then this image . why they are giving different outputs when i want the lower bound of 6?

Full text and comments »

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

By CantLoseNow, history, 3 months ago, In English

so i know how lowerbound and upperbound works for a vector sorted in ascending order. But what if i arrange the vector in descending order? i wanted to know the answer and i searched it on cppreference but i was not able to understand it there. so i also wrote a small code to test it out. According to the definition of lower bound in geeksforgeeks —

"The lower_bound() method in C++ is used to return an iterator pointing to the first element in the range [first, last) which has a value not less than val."

so if i wrote a code like this:

#include<bits/stdc++.h>
using namespace std;

int main(){

	int n;
	cin >> n;
	int who_to_compare;
	cin >> who_to_compare;

	vector<int> v;

	for(int i=0;i<n;i++){
		int temp;
		cin >> temp;
		v.push_back(temp);
	}

	sort(v.begin(), v.end(), greater<int>());
	auto it = lower_bound(v.begin(), v.end(), who_to_compare);

	cout << v[it-v.begin()];
	
}

and my input is : 5 4 5 3 7 8 5

then the output is : 8

-> which is like correct according to me since 8 is the first number which is greater than 4 and is the first number in the range to be greater than 4 .(idk if i am correct, pls correct me here).

but when my input is : 5 6 5 3 7 8 5

then the output is : 0

-> why is it so ? shouldn't it be 8? because 8 is the first element in the range to be greater than 6.

Please help me understand this whole thing better...

Full text and comments »

 
 
 
 
  • Vote: I like it
  • -10
  • Vote: I do not like it

By CantLoseNow, history, 3 months ago, In English

so i was solving a cses question and i had a confusion...why dont we sort a set or multiset before applying lower bound and upper bound? i saw some solutions and they just simply added the elements and directly applied lower bound and upper bound.

Full text and comments »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By CantLoseNow, history, 3 months ago, In English

i was seeing a solution of my question and i encountered this statement — "since we need to do some deletions here, we cant use vectors, since its not directly possible in vectors." my question is that dont we have the erase() function in vectors? then why not use it?

Full text and comments »

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

By CantLoseNow, history, 3 months ago, In English

so i was solving this question from searching and sorting section of cses. it took me a hour to solve it through 2 pointers. But i was wondering what would be the approach to solve if the gondola can contain 3 children instead of 2. And what if the limit was 4 children? do these type of questions have some same approach? Can someone please help me???

Full text and comments »

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

By CantLoseNow, history, 3 months ago, In English

i was solving this problem 1738B - Prefix Sum Addicts . my submission 177418929 gives error on 1 testcase....help me please....otherwise i wont be able to move myself to other problems.

Full text and comments »

 
 
 
 
  • Vote: I like it
  • -1
  • Vote: I do not like it

By CantLoseNow, history, 3 months ago, In English

so everyone told me to practise...but the problem is that i set the problem set of codeforces to 1000-1200. Then i try to solve from the first problem. i was not able to solve it so i read the editorial or watched the solution from youtube. Then i move to another question from problemset. again i failed to solve it and then moved to another problem after watching the previous problem solutions. so overall i am not able to solve any problem by myself. i am new so need some guidance. do i have to continue doing this or am i doing something wrong.

Full text and comments »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By CantLoseNow, history, 4 months ago, In English

200A - Cinema — i was solving this problem which was in a20j ladder A(No.100) . And i solved it using brute force using this submission 173330360 . it worked for all testcases in my computer but on codeforces it went to an error of wrong answer. the input was totally same. i even tried an online compiler and that website gave me an even different answer than both of the previous answers. please help me. i know the solution is kinda messed up since i just started competitive programming but please i need help.

Full text and comments »

 
 
 
 
  • Vote: I like it
  • -1
  • Vote: I do not like it