QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#288455 | #5649. Spinach Pizza | Sorting# | Compile Error | / | / | C++14 | 1.5kb | 2023-12-22 18:04:38 | 2023-12-22 18:04:40 |
Judging History
answer
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
struct Point{
ll x, y;
int idx;
friend bool operator<(const Point &l, const Point &r){
return l.idx < r.idx;
}
friend bool operator==(const Point &l, const Point &r){
return l.idx == r.idx;
}
};
const int N = 100 + 3;
int n;
vector<Point> p;
ll area2(Point a, Point b, Point c){
return a.x * b.y + b.x * c.y + c.x * a.y - a.x * c.y - b.x * a.y - c.x * b.y;
}
pair<ll, int> smallest(vector<Point> p){
pair<ll, int> answer;
answer.first = 2e18;
for(int i = 0; i < p.size(); ++i){
int prv = (i - 1 + (int)p.size()) % p.size();
int nxt = (i + 1) % p.size();
pair<ll, int> cand;
cand.first = area2(p[prv], p[i], p[nxt]);
cand.second = i;
answer = min(answer, cand);
}
return answer;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
p.resize(n);
for(int i = 0; i < n; ++i){
cin >> p[i].x >> p[i].y;
p[i].idx = i + 1;
}
cout << "Alberto" << endl;
for(int turn = 0; turn < n - 2; ++turn){
if(turn % 2 == 0){
auto small = smallest(p);
cout << p[small.second].idx << endl;
p.erase(p.begin() + small.second);
}
else{
int idx;
cin >> idx;
p.erase(find(p.begin(), p.end(), Point{0, 0, idx}));
}
}
}
詳細信息
answer.code: In function ‘int main()’: answer.code:65:25: error: no matching function for call to ‘find(std::vector<Point>::iterator, std::vector<Point>::iterator, Point)’ 65 | p.erase(find(p.begin(), p.end(), Point{0, 0, idx})); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/locale_facets.h:48, from /usr/include/c++/11/bits/basic_ios.h:37, from /usr/include/c++/11/ios:44, from /usr/include/c++/11/ostream:38, from /usr/include/c++/11/iostream:39, from answer.code:1: /usr/include/c++/11/bits/streambuf_iterator.h:421:5: note: candidate: ‘template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >, const _CharT2&)’ 421 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/11/bits/streambuf_iterator.h:421:5: note: template argument deduction/substitution failed: answer.code:65:25: note: ‘__gnu_cxx::__normal_iterator<Point*, std::vector<Point> >’ is not derived from ‘std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >’ 65 | p.erase(find(p.begin(), p.end(), Point{0, 0, idx})); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~