이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+2;
using ll = long long;
const int mod = 1e9 + 7;
int n;
struct point {
ll x, y;
point operator - (const point &other) const {
return {x - other.x, y - other.y};
}
};
point p[1002];
ll ccw (point a, point b) {
return a.x * b.y - a.y * b.x;
}
bool cmp (point a, point b) {
if ((a.x > 0) != (b.x > 0))
return a.x < b.x;
return ccw(a, b) > 0;
}
ll pw[1002];
int main ()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
pw[0] = 1;
for (int i = 1; i <= n; i++) {
cin >> p[i].x >> p[i].y;
pw[i] = 2ll * pw[i - 1] % mod;
}
ll ans = 0;
for (int i = 1; i <= n; i++) {
vector<point>v;
for (int j = 1; j <= n; j++)
if (j != i)
v.push_back(p[j] - p[i]);
sort(v.begin(), v.end(), cmp);
int j = 0;
ll x = 0;
for (int i = 0; i < n - 1; i++) {
while (ccw(v[i], v[(j + 1) % (n - 1)]) > 0)
j++;
x = (x + pw[(j - i + (n - 1)) % (n - 1)]) % mod;
}
x = pw[n] - x;
if (x < 0) x += mod;
ans += x;
if (ans >= mod) ans %= mod;
}
cout << (ans-n + mod) % mod;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |