QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#373234 | #7730. Convex Checker | dodola | Compile Error | / | / | C++14 | 3.4kb | 2024-04-01 11:50:00 | 2024-04-01 11:50:02 |
Judging History
你现在查看的是最新测评结果
- [2024-07-04 19:27:17]
- hack成功,自动添加数据
- (/hack/727)
- [2024-07-04 19:17:30]
- hack成功,自动添加数据
- (/hack/726)
- [2024-04-01 11:50:02]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2024-04-01 11:50:00]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
const ld eps = 1e-18;
const ld pi = acos(-1.0);
/*
符合洛谷题目格式的代码
*/
struct point {
ld x, y;
point operator+(const point& p)const {
return { x + p.x,y + p.y };
}
point operator-(const point& p)const {
return { x - p.x,y - p.y };
}
bool operator==(const point& p)const {
return p.x == x && p.y == y;
}
point rotate(ld t)const {
return { x * cos(t) - y * sin(t), x * sin(t) + y * cos(t) };
}
point rot90()const {
return { -y,x };
}
};
struct line {
point s, t;
};
int sgn(ld x) {
if (fabs(x) < eps) return 0;
return x < 0 ? -1 : 1;
}
ld sqr(ld x) {
return x * x;
}
ld dis(const point& a, const point& b) {
return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}
ld dot(const point& a, const point& b) {
return a.x * b.x + a.y * b.y;
}
ld det(const point& a, const point& b) {
return a.x * b.y - a.y * b.x;
}
vector<point>Andrew(vector<point>& p) {
sort(p.begin(), p.end(), [](const point& a, const point& b) {
return a.x == b.x ? a.y < b.y : a.x < b.x;
});
vector<point> res;
for (int i = 0; i < p.size(); i++) { // 下凸壳
while (res.size() > 1
&& det(res.back() - res[res.size() - 2], p[i] - res[res.size() - 2]) <= 0)
res.pop_back();
res.push_back(p[i]);
}
int k = res.size();
for (int i = p.size() - 2; i >= 0; i--) { // 上凸壳
while (res.size() > k
&& det(res.back() - res[res.size() - 2], p[i] - res[res.size() - 2]) <= 0)
res.pop_back();
res.push_back(p[i]);
}
res.pop_back(); // 删除重复的点,即首尾相同
return res;
}
bool turn_left(const point& a, const point& b, const point& c) {
return sgn(det(b - a, c - a)) > 0;
}
vector<point> Graham(vector<point>& p) {
point base = *min_element(p.begin(), p.end(), [](const point& a, const point& b) {
return a.y == b.y ? a.x < b.x : a.y < b.y;
});
sort(p.begin(), p.end(), [&](const point& u, const point& v) {
int s = sgn(det(u - base, v - base));
if (s)return s > 0;
return sgn(dis(u, base) - dis(v, base)) < 0;
});
vector<point>res;
for (auto i : p) {
while (res.size() > 1
&& !turn_left(res[res.size() - 2], res.back(), i))
res.pop_back();
res.push_back(i);
}
return res;
}
// 求凸包的周长
ld convex_perimeter(vector<point>& p) {
ld res = 0;
for (int i = 0; i < p.size(); i++)
res += dis(p[i], p[(i + 1) % p.size()]);
return res;
}
bool convex_checker(vector<point>& p) {
vector<point> res = Andrew(p);
if (res.size() != p.size())return false;
while (p.size() && p.front() != res.front()) {
res.push_back(res.front());
res.erase(res.begin());
}
for (int i = 0; i < p.size(); i++) {
if (p[i] != (res[i]))return false;
}
return true;
}
void solve() {
ll n;cin >> n;
vector<point> p(n);
for (ll i = 0;i < n;i++) {
cin >> p[i].x >> p[i].y;
}
if (convex_checker(p)) {
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}
}
int main() {
solve();
return 0;
}
Details
answer.code: In function ‘bool convex_checker(std::vector<point>&)’: answer.code:108:34: error: no match for ‘operator!=’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<point>, point>::value_type’ {aka ‘point’} and ‘__gnu_cxx::__alloc_traits<std::allocator<point>, point>::value_type’ {aka ‘point’}) 108 | while (p.size() && p.front() != res.front()) { | ~~~~~~~~~ ^~ ~~~~~~~~~~~ | | | | | __gnu_cxx::__alloc_traits<std::allocator<point>, point>::value_type {aka point} | __gnu_cxx::__alloc_traits<std::allocator<point>, point>::value_type {aka point} In file included from /usr/include/c++/13/regex:68, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:181, from answer.code:1: /usr/include/c++/13/bits/regex.h:1132:5: note: candidate: ‘template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)’ 1132 | operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/13/bits/regex.h:1132:5: note: template argument deduction/substitution failed: answer.code:108:47: note: ‘__gnu_cxx::__alloc_traits<std::allocator<point>, point>::value_type’ {aka ‘point’} is not derived from ‘const std::__cxx11::sub_match<_BiIter>’ 108 | while (p.size() && p.front() != res.front()) { | ^ /usr/include/c++/13/bits/regex.h:1212:5: note: candidate: ‘template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)’ 1212 | operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/regex.h:1212:5: note: template argument deduction/substitution failed: answer.code:108:47: note: ‘__gnu_cxx::__alloc_traits<std::allocator<point>, point>::value_type’ {aka ‘point’} is not derived from ‘std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>’ 108 | while (p.size() && p.front() != res.front()) { | ^ /usr/include/c++/13/bits/regex.h:1305:5: note: candidate: ‘template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)’ 1305 | operator!=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/regex.h:1305:5: note: template argument deduction/substitution failed: answer.code:108:47: note: ‘__gnu_cxx::__alloc_traits<std::allocator<point>, point>::value_type’ {aka ‘point’} is not derived from ‘const std::__cxx11::sub_match<_BiIter>’ 108 | while (p.size() && p.front() != res.front()) { | ^ /usr/include/c++/13/bits/regex.h:1379:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)’ 1379 | operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/regex.h:1379:5: note: template argument deduction/substitution failed: answer.code:108:47: note: ‘__gnu_cxx::__alloc_traits<std::allocator<point>, point>::value_type’ {aka ‘point’} is not derived from ‘const std::__cxx11::sub_match<_BiIter>’ 108 | while (p.size() && p.front() != res.front()) { | ^ /usr/include/c++/13/bits/regex.h:1473:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)’ 1473 | operator!=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/regex.h:1473:5: note: template argument deduction/substitution failed: answer.code:108:47: note: ‘__gnu_cxx::__alloc_traits<std::allocator<point>, point>::value_type’ {aka ‘point’} is not derived from ‘const std::__cxx11::sub_match<_BiIter>’ 108 | while (p.size() && p.front() != res.front()) { | ^ /usr/include/c++/13/bits/regex.h:1547:5: note: candidate: ‘template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)’ 1547 | operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/regex.h:1547:5: note: template argument deduction/substitution failed: answer.code:108:47: note: ‘__gnu_cxx::__alloc_traits<std::allocator<point>, point>::value_type’ {aka ‘point’} is not derived from ‘const std::__cxx11::sub_match<_BiIter>’ 108 | while (p.size() && p.front() != res.front()) ...