Alpha_Q's blog

By Alpha_Q, history, 4 years ago, In English

We invite you to participate in CodeChef’s June Cook-Off, this Sunday, 21st June, from 9:30 pm to 12:00 am IST. 2.5 hours, 5 problems.

We will also be hosting a live problems discussion session for Cook-Off problems with our panelist Rajarshi RestingRajarshi Basu on 23rd June, 4 pm IST. You can register by clicking on the GOING button at the top right corner here. Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here.

Joining us on the problem setting panel are:

Prizes: Top 10 Indian and top 10 Global participants will receive CodeChef laddus, with which the winners can claim cool CodeChef goodies. Know more here.

Good luck and have fun!

Full text and comments »

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

By Alpha_Q, history, 5 years ago, In English

Say yo want a set of points sorted in some counterclockwise order. What is the best (fast, precise, short) way to do it? The atan2l function is precise and short but way too slow.

Update: One of the previous entries were wrong. I like the following one which hopefully works.

inline bool up (point p) {
  return p.y > 0 or (p.y == 0 and p.x >= 0);
}

sort(v.begin(), v.end(), [] (point a, point b) {
  return up(a) == up(b) ? a.x * b.y > a.y * b.x : up(a) < up(b);
});

Full text and comments »

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