結果

問題 No.947 ABC包囲網
ユーザー Mayimg
提出日時 2020-07-26 14:38:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 827 bytes
コンパイル時間 2,437 ms
コンパイル使用メモリ 198,372 KB
最終ジャッジ日時 2025-01-12 05:55:14
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 60
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const long double esp = 1e-12;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<long double> v;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    int g = __gcd(abs(x), abs(y));
    x /= g;
    y /= g;
    v.push_back(atan2(x, y));
    v.push_back(v.back() + M_PI * 2);
    v.push_back(v.back() + M_PI * 2);
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int j = i;
    while (v[j] - v[i] <= M_PI + esp) j++;
    int k = j;
    for (int c = i + 1; c < j; c++) {
      if (v[i] == v[c]) continue;
      if (v[c] - v[i] >= M_PI - esp) break;
      while (v[k] - v[c] < M_PI - esp) k++;
      ans += k - j;
    }
  }
  cout << ans / 3 << endl;
  return 0;
}
0