結果
| 問題 |
No.1144 Triangles
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-31 23:26:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,551 bytes |
| コンパイル時間 | 1,736 ms |
| コンパイル使用メモリ | 172,344 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 21:38:32 |
| 合計ジャッジ時間 | 4,647 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 WA * 16 |
ソースコード
#include <bits/stdc++.h>
using ll = long long;
const int maxn = 2e3 + 3;
const ll mo = 1e9 + 7, tp = 5e8 + 4;
int n, m;
struct vec {
ll x, y;
vec operator-(const vec &k) const {
return {x - k.x, y - k.y};
}
ll cross(const vec &k) const {
return x * k.y - y * k.x;
}
} a[maxn], b[maxn];
ll ans = 0, uxs, vxs, uys, vys;
void addU(int i, ll d) {
uxs += b[i].x * d;
uys += b[i].y * d;
}
void addV(int i, ll d) {
vxs += b[i].x * d;
vys += b[i].y * d;
}
void subsolve() {
std::sort(b, b + m, [](const vec &u, const vec &v) {
return u.cross(v) > 0;
});
uxs = vxs = uys = vys = 0;
for(int i = 0; i < m; ++i)
addV(i, 1);
for(int i = 0, j = 0; i < m;) {
while(j - i < m && b[i].cross(b[j % m]) >= 0) {
addV(j % m, -1);
addU(j % m, +1);
j += 1;
}
vec us{uxs, uys};
vec vs{vxs, vys};
ans = (ans + std::abs(b[i].cross(us)) % mo + std::abs(b[i].cross(vs)) % mo) % mo;
if(j > i) {
addU(i, -1);
addV(i, +1);
i += 1;
} else {
i += 1;
j += 1;
}
}
}
void solve(int s) {
m = 0;
for(int j = s + 1; j < n; ++j) {
b[m++] = a[j] - a[s];
}
subsolve();
}
int main() {
scanf("%d", &n);
for(int i = 0; i < n; ++i) {
scanf("%lld%lld", &a[i].x, &a[i].y);
}
for(int i = 0; i < n; ++i) {
solve(i);
}
printf("%lld\n", (ans * tp % mo + mo) % mo);
return 0;
}