Блог пользователя Alpha_Q

Автор Alpha_Q, история, 4 года назад, По-английски

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!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +129
  • Проголосовать: не нравится

Автор Alpha_Q, история, 5 лет назад, По-английски

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);
});

Полный текст и комментарии »

  • Проголосовать: нравится
  • +141
  • Проголосовать: не нравится