QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#241845 | #7730. Convex Checker | fstqwq | WA | 0ms | 3748kb | C++14 | 1.2kb | 2023-11-06 18:28:32 | 2023-11-06 18:28:32 |
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-06 18:28:32]
- 提交
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;
}
int sgn(LL x) {
return x > 0 ? 1 : (x < 0 ? -1 : 0);
}
bool isconvex(vector <point> &p) {
bool s[3];
int n = (int) p.size();
memset(s, false, sizeof(s));
for (int i = 0; i < n; i++) {
int j = (i + 1) % n;
int k = (j + 1) % n;
s[sgn(det(p[j] - p[i], p[k] - p[i])) + 1] = true;
if (s[0] && s[2]) return false;
}
return !s[1];
}
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());
puts (isconvex(a) ? "Yes" : "No");
}
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int T = 1;
for (int ca = 1; ca <= T; ca ++)
work();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3484kb
input:
3 0 0 1 0 0 1
output:
Yes
result:
ok answer is YES
Test #2:
score: 0
Accepted
time: 0ms
memory: 3600kb
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: 3528kb
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: 3484kb
input:
3 0 0 0 0 0 0
output:
No
result:
ok answer is NO
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3748kb
input:
5 1 0 4 1 0 1 2 0 3 2
output:
Yes
result:
wrong answer expected NO, found YES