Parvej's blog

By Parvej, history, 2 months ago, In English

We know that a tree has either 1 or 2 centroids. I can find one centroid using simple dfs.

But, if a tree has 2 centroids, Is there a way to efficiently find the other one?

In case you don't know about centroids of a tree. See here

Read more »

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

By Parvej, history, 7 months ago, In English

How can I find all the simple cycles in an undirected graph?

126615260_419079712777006_8560932289449234104_n.png In the picture, there are 3 simple cycle:

  1. 1-2-3

  2. 1-2-4-5

  3. 1-3-2-4-5

How can I print all of them?

Read more »

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

By Parvej, history, 14 months ago, In English

In this problem 1008C - Reorder the Array

I used upper_bound(multiset.begin(),multiset.end(),x) and got TLE.

TLE Sub: 77006832

But when I used multiset.upper_bound(x), I got accepted!

AC Sub:77081261

Can anyone explain to me why inbuilt upper_bound() is slower than the member upper_bound() function of std::multiset?

Read more »

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