QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#236402 | #7730. Convex Checker | fstqwq | WA | 1ms | 3816kb | C++14 | 1.3kb | 2023-11-03 22:15:46 | 2023-11-03 22:15:47 |
Judging History
你现在查看的是最新测评结果
- [2024-07-04 19:27:17]
- hack成功,自动添加数据
- (/hack/727)
- [2024-07-04 19:17:30]
- hack成功,自动添加数据
- (/hack/726)
- [2023-12-08 14:40:48]
- hack成功,自动添加数据
- (//qoj.ac/hack/493)
- [2023-11-07 10:32:52]
- hack成功,自动添加数据
- (//qoj.ac/hack/426)
- [2023-11-07 10:28:41]
- hack成功,自动添加数据
- (//qoj.ac/hack/425)
- [2023-11-03 22:15:46]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double LD;
typedef pair <int, int> pii;
const LD PI = acos(-1.0);
#define cp const point &
struct point {
LL x, y;
point () {}
point (LL xx, LL yy) { x = xx, y = yy; }
point operator + (cp a) const { return {x + a.x, y + a.y}; }
point operator - (cp a) const { return {x - a.x, y - a.y}; }
bool operator < (cp a) const {
return make_pair(x, y) < make_pair(a.x, a.y);
}
};
LL det (point a, point b) {
return a.x * b.y - b.x * a.y;
}
void work () {
int n;
cin >> n;
vector <point> a;
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
a.push_back({x, y});
}
if (det(a[1] - a[0], a[2] - a[0]) < 0) reverse(a.begin(), a.end());
bool flag = true;
double ans = 0;
for (int i = 0; i < n; i++) {
auto u = a[(i + 2) % n] - a[(i + 1) % n];
auto v = a[i] - a[(i + 1) % n];
auto uu = atan2(u.y, u.x);
auto vv = atan2(v.y, v.x);
auto d = vv - uu;
if (d < 0) d += 2 * PI;
if (abs(d) <= 1e-12 && abs(PI - d) <= 1e-12) flag = false;
ans += d;
}
puts (flag && abs(ans - (n - 2) * PI) < 0.1 ? "Yes" : "No");
}
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int T = 1;
for (int ca = 1; ca <= T; ca ++)
work();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3672kb
input:
3 0 0 1 0 0 1
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
4 0 0 0 1 1 1 1 0
output:
Yes
result:
ok answer is YES
Test #3:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
4 0 0 0 3 1 2 1 1
output:
Yes
result:
ok answer is YES
Test #4:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
3 0 0 0 0 0 0
output:
No
result:
ok answer is NO
Test #5:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
5 1 0 4 1 0 1 2 0 3 2
output:
No
result:
ok answer is NO
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3688kb
input:
5 0 0 1000000000 0 1000000000 500000000 1000000000 1000000000 0 1000000000
output:
Yes
result:
wrong answer expected NO, found YES