結果
| 問題 |
No.947 ABC包囲網
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-15 17:01:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 1,068 bytes |
| コンパイル時間 | 1,682 ms |
| コンパイル使用メモリ | 173,480 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-02 18:16:46 |
| 合計ジャッジ時間 | 3,035 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 60 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
constexpr ld PI = 3.14159265358979;
constexpr ld EPS = 1e-10;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> px(n), py(n);
vector<ld> th(n);
for (int i = 0; i < n; ++i) {
cin >> px[i] >> py[i];
th[i] = atan2((ld)py[i], (ld)px[i]);
}
sort(th.begin(), th.end());
vector<int> tar(n);
for (int i = 0; i < n; ++i) {
tar[i] = lower_bound(th.begin() + i, th.end(), th[i] + PI + EPS) - th.begin();
//cerr << tar[i] << endl;
}
ll ans = 0;
for (int i = 1; i < n - 1; ++i) {
int L = lower_bound(th.begin(), th.begin() + i, th[i] - PI + EPS) - th.begin();
int R = lower_bound(th.begin() + i + 1, th.end(), th[i] + PI - EPS) - th.begin();
//cerr << L << " " << i << " " << R << endl;
for (int j = L; j < i; ++j) {
ans += max(R - max(i + 1, tar[j]), 0);
}
}
cout << ans << "\n";
return 0;
}