結果
問題 | No.1144 Triangles |
ユーザー |
|
提出日時 | 2020-07-31 23:20:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,761 bytes |
コンパイル時間 | 1,672 ms |
コンパイル使用メモリ | 177,764 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 21:32:45 |
合計ジャッジ時間 | 8,427 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 24 WA * 1 |
ソースコード
// 21:50 - 22:02 #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define all(x) x.begin(), x.end() #define lch (o << 1) #define rch (o << 1 | 1) typedef double db; typedef long long ll; typedef unsigned int ui; typedef pair<int, int> pint; typedef tuple<int, int, int> tint; const int N = 2000 + 5; const int MOD = 1e9 + 7; const int INV3 = 333333336; const int INF = 0x3f3f3f3f; const ll INF_LL = 0x3f3f3f3f3f3f3f3f; struct Point { ll x, y; Point operator+(Point rhs) { return (Point){(x + rhs.x) % MOD, (y + rhs.y) % MOD}; } Point operator-(Point rhs) { return (Point){(x - rhs.x) % MOD, (y - rhs.y) % MOD}; } ll operator*(Point rhs) { return (x * rhs.y - y * rhs.x) % MOD; } }; Point p[N]; int n; ll Solve(int rt) { vector<pair<double, Point>> _pts; for (int i = 1; i <= n; i++) if (i != rt) { auto tmp = p[i] - p[rt]; if (tmp.x != 0 || tmp.y != 0) _pts.push_back(make_pair(atan2(tmp.y, tmp.x), tmp)); } sort(all(_pts), [](pair<double, Point> &a, pair<double, Point> &b) { return a.fi < b.fi; }); int m = _pts.size(); vector<Point> pts; for (int i = 0; i < m; i++) pts.push_back(_pts[i].se); for (int i = 0; i < m; i++) pts.push_back(_pts[i].se); Point sum = (Point){0, 0}; ll ret = 0; int r = 0; for (int i = 0; i < m; i++) { while (r < i + m && pts[i] * pts[r] >= 0) { sum = sum + pts[r]; r++; } ret = (ret + pts[i] * sum) % MOD; sum = sum - pts[i]; } return ret; } int main() { ios::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) cin >> p[i].x >> p[i].y; ll ans = 0; for (int i = 1; i <= n; i++) { ll tmp = Solve(i); ans = (ans + tmp) % MOD; } ans = ans * INV3 % MOD; cout << (ans % MOD + MOD) % MOD << endl; return 0; }