abba5's blog

By abba5, history, 3 months ago, In English

I was trying to submit this -> Remove Max Number of Edges to Keep Graph Fully Traversable question.
but I got TLE because of sort using rbegin

sort( edges.rbegin(), edges.rend())

but after change with comparator funtction code got accepted.

sort(edges.begin(), edges.end(), [&](vector <int> &a, vector <int> &b){
            return a[0] > b[0];

Submission Using rbegin

Submission Using comparator

I tried to run this in local and got similar performance but when I used some different build command I got 2x time difference for $$$N = 10^5$$$

Build command:

  1. g++ a.cpp

  2. g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -DLOCAL a.cpp

output using 1st build command:


output using 2nd build command:


Following code I used for bench-marking.

Bench-marking code

Can anyone explain why this time difference happening?
Will this happen in code-forces also?

Read more »

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

By abba5, history, 17 months ago, In English

there is $$$N$$$ number of cites in one dimension. the location of the city is $$$a_{i}$$$ you have to place $$$k$$$ ATM such that the sum of all the cities to its nearest ATM distance is minimum.

I don't remember constraints but it was not big.

the question was asked in Honeywell Hiring Challange(closed).

Brute Force solution

$$$N = 3$$$

$$$A = [1, 2, 3]$$$

$$$K = 1$$$

$$$ans = 2$$$

Thanks in Advance!

Read more »

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

By abba5, history, 2 years ago, In English

Question was asked in this contest !!! [IEMATICS](

Read more »

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