Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.


By nahidhasan98 · Limits 1s, 512 MB

You will be given two-dimensional coordinates (x,y)(x, y) of NN points. Your task is to identify KK points from them that are lying in a straight line (This line should contain exactly KK points). It is guaranteed that all points are unique and there is exactly one such line exists in which exactly KK points lie.


The first line of the input contains two integers NN and KK.

The next NN lines contain the description of NN points. The ii th line contains two integers xix_i and yiy_i that denote the coordinates of the ii th point.


  • 2KN100002 \leq K \leq N \leq 10000

  • 1000xi,yi1000-1000 \leq x_i, y_i \leq 1000


Print the coordinates of the KK points one line each according to the input order.


4 3
1 1
1 2
2 2
3 3
1 1
2 2
3 3



64% Solution Ratio

s_semicolonEarliest, 1M ago

RakibJoyFastest, 0.0s

s_semicolonLightest, 561 kB

serotoninShortest, 1321B


Login to submit


Discussion: We all are known to the term slope of a line. It is defined as the change in the y coord...

Toph uses cookies. By continuing you agree to our Cookie Policy.