結果
問題 |
No.1144 Triangles
|
ユーザー |
|
提出日時 | 2020-07-31 23:12:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,621 bytes |
コンパイル時間 | 1,744 ms |
コンパイル使用メモリ | 175,052 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 21:09:52 |
合計ジャッジ時間 | 37,106 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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<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(tmp); } sort(all(pts), [](Point a, Point b) { return atan2(a.y, a.x) < atan2(b.y, b.x); }); int m = pts.size(); for (int i = 0; i < m; i++) pts.push_back(pts[i]); 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; }