QOJ.ac
QOJ
ID | 提交记录ID | 题目 | Hacker | Owner | 结果 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|
#426 | #236386 | #7730. Convex Checker | ucup-team1209 | fstqwq | Success! | 2023-11-07 10:32:43 | 2023-11-07 10:32:43 |
详细
Extra Test:
Wrong Answer
time: 0ms
memory: 3776kb
input:
8 0 0 1 0 1 1 0 1 -1 -1 2 -1 2 2 -1 2
output:
Yes
result:
wrong answer expected NO, found YES
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#236386 | #7730. Convex Checker | fstqwq | WA | 16ms | 5292kb | C++14 | 1.1kb | 2023-11-03 22:04:05 | 2023-11-07 10:32:53 |
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair <int, int> pii;
#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;
for (int i = 2; i < n; i++) {
flag &= det(a[i - 1] - a[0], a[i] - a[0]) > 0;
}
for (int i = 0; i < n; i++) {
flag &= det(a[(i + 1) % n] - a[i], a[(i + 2) % n] - a[(i + 1) % n]) > 0;
}
puts (flag ? "Yes" : "No");
}
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int T = 1;
for (int ca = 1; ca <= T; ca ++)
work();
}