QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#413895#5649. Spinach Pizzathesupermarketisgoingtome#WA 1ms3592kbC++172.7kb2024-05-18 11:40:412024-05-18 11:40:42

Judging History

你现在查看的是最新测评结果

  • [2024-05-18 11:40:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3592kb
  • [2024-05-18 11:40:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
	friend ostream& operator<<(ostream& os, P p) {
		return os << "(" << p.x << "," << p.y << ")"; }
};

typedef Point<int> P;

template<class T>
T polygonArea2(vector<Point<T>>& v) {
	T a = v.back().cross(v[0]);
	rep(i,0,sz(v)-1) a += v[i].cross(v[i+1]);
	return abs(a);
}
set<int>s;
vector<P>arr(105);
int solve(){
	vector<int>vec;
	for(int nxt: s){
		vec.push_back(nxt);
	}
	vector<P>poly = {arr[vec[0]],arr[vec[1]],arr[vec.back()]};
	int res = polygonArea2(poly);
	pair<int,int>p = {res,vec[0]};
	for(int i = 1; i+1<vec.size(); i++){
		poly = {arr[vec[i-1]],arr[vec[i]],arr[vec[i+1]]};
		res = polygonArea2(poly);
		p = min(p,{res,vec[i]});
	}
	poly = {arr[vec[0]], arr[vec[vec.size()-2]], arr[vec.back()]};

	p = min(p, {polygonArea2(poly), vec.back()});
	return p.second;
}
signed main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i = 1; i<=n; i++){
		int x,y;
		cin >> x >> y;
		arr[i] = P{x,y};
	}
	if(n%2==0){
		cout << "Albert" << endl;
	}
	else{
		cout << "Beatrice" << endl;
	}
	
	for(int i = 1; i<=n; i++){
		s.insert(i);
	}
	for(int i = n; i>=3; i--){
		if(i%2==0){
			int v = solve();
			cout << v << endl;
			s.erase(v);
		}
		else{
			int q;
			cin >> q;
			s.erase(q);
		}
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3592kb

input:

4
0 0
6 1
5 3
1 4

output:

Albert
3

result:

wrong answer unrecognised player name