QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#675374#9253. Prism Palacewoodie_0064WA 56ms9860kbC++202.0kb2024-10-25 18:27:032024-10-25 18:27:03

Judging History

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

  • [2024-10-25 18:27:03]
  • 评测
  • 测评结果:WA
  • 用时:56ms
  • 内存:9860kb
  • [2024-10-25 18:27:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef double db;
const db EPS = 1e-9;
#define rep(i,j,k) for(int i = j;i < k;i++)
inline int sign(db a) { return a < -EPS ? -1 : a > EPS; }

inline int cmp(db a, db b){ return sign(a-b); }

struct P {
	db x, y;
	P() {}
	P(db _x, db _y) : x(_x), y(_y) {}
	P operator+(P p) { return {x + p.x, y + p.y}; }
	P operator-(P p) { return {x - p.x, y - p.y}; }
	P operator*(db d) { return {x * d, y * d}; }
	P operator/(db d) { return {x / d, y / d}; }
	
	bool operator<(P p) const { 
		int c = cmp(x, p.x);
		if (c) return c == -1;
		return cmp(y, p.y) == -1;
	}
	
	bool operator==(P o) const{
		return cmp(x,o.x) == 0 && cmp(y,o.y) == 0;
	}
	db alpha() { return atan2(y, x); }
	db dot(P p) { return x * p.x + y * p.y; }
	void read() { cin>>x>>y; }
	void write() {cout<<"("<<x<<","<<y<<")"<<endl;}
	db abs() { return sqrt(abs2());}
	db abs2() { return x * x + y * y; }
	P rot(db an){ return {x*cos(an) - y*sin(an),x*sin(an) + y*cos(an)}; }
};

#define cross(p1,p2,p3) ((p2.x-p1.x)*(p3.y-p1.y)-(p3.x-p1.x)*(p2.y-p1.y))
#define crossOp(p1,p2,p3) sign(cross(p1,p2,p3))

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
	int n;cin >> n;
	vector <P> a(n * 2);
	for(int i = 0;i < n;i++) {
		a[i].read();
		a[i + n] = a[i];
	}
	db ans = 0,pi = acos(-1);
	auto getdegree = [&] (P x,P y) {
		db deg = x.dot(y) / x.abs2() / y.abs2();
		return deg < 0 ? pi + acos(deg) : acos(deg);
	};
	for(int i = 1;i <= n;i++) {
		P x = a[i - 1] - a[i],y = a[i + 2] - a[i + 1],mid = a[i + 1] - a[i];
		db deg = acos(x.dot(y) / x.abs() / y.abs());
//		x.write();y.write();
//		cout << x.dot(y) << ' ' << x.abs() << ' ' << y.abs() << '\n';
		if(getdegree(x,mid) + getdegree(y,mid * (-1.0)) > pi) continue;
		if(deg < 0) continue;
		ans += deg;
//		cout << deg << ' ' << ans << ' ' << i << '\n';
	}
//	cout << acos(-1) << ' ';
	cout << ans / pi << '\n';
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 4180kb

input:

3
0 0
1 0
0 1

output:

1.0000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 4052kb

input:

4
0 0
0 1
1 1
1 0

output:

0.0000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 4024kb

input:

4
0 0
0 3
1 2
1 1

output:

0.5000000000

result:

ok found '0.5000000', expected '0.5000000', error '0.0000000'

Test #4:

score: -100
Wrong Answer
time: 56ms
memory: 9860kb

input:

199996
719157942 80035870
719158808 80033199
719160795 80027070
719162868 80020675
719165635 80012139
719166422 80009711
719166927 80008153
719168388 80003645
719168539 80003179
719168806 80002355
719168864 80002176
719169119 80001389
719171067 79995376
719173806 79986921
719175195 79982633
71917686...

output:

0.0000000000

result:

wrong answer 1st numbers differ - expected: '0.0000777', found: '0.0000000', error = '0.0000777'