QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#748499#9576. Ordainer of Inexorable JudgmentZLYFWA 1ms4276kbC++202.0kb2024-11-14 20:34:062024-11-14 20:34:06

Judging History

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

  • [2024-12-23 14:23:26]
  • hack成功,自动添加数据
  • (/hack/1303)
  • [2024-12-06 11:32:56]
  • hack成功,自动添加数据
  • (/hack/1271)
  • [2024-11-14 21:58:28]
  • hack成功,自动添加数据
  • (/hack/1181)
  • [2024-11-14 20:34:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4276kb
  • [2024-11-14 20:34:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
const double pi=acos(-1),eps=1e-12;
const int N=105;
int n;double X0,Y0,d,t;
struct Point{
	double x,y;
	Point operator-(const Point &b){
		return Point{x-b.x,y-b.y};
	}
	Point operator+(const Point &b){
		return Point{x+b.x,y+b.y};
	}
	friend double operator^(const Point &a,const Point &b){
		return a.x*b.y-a.y*b.x;
	}
}p[N];
double change(double th){
	while(th>=pi*2)
		th-=pi*2;
	while(th<0)
		th+=pi*2;
	return th;
}
bool check(double th,int sgn){
	Point o={cos(th)*d,sin(th)*d};
	Point v={cos(th-pi/2*sgn),sin(th-pi/2*sgn)};
//	cout<<o.x<<" "<<o.y<<"\n";
//	cout<<v.x<<" "<<v.y<<"\n";
	for(int i=0;i<n;i++){
		Point a=p[i]-o;
//		cout<<a.x<<" "<<a.y<<" "<(v^a)<<"\n";
		if(sgn==1){
			if((v^a)<-eps)
				return 0;
		}
		if(sgn==-1){
			if((v^a)>eps)
				return 0;
		}
	}
//	cout<<"!\n";
	return 1;
}
double inter(double l,double r,double u,double v){
	if(r<u||l>v)
		return 0;
	return min(r,v)-max(l,u);
}
void print(double th){
	cout<<cos(th)*d<<" "<<sin(th)*d<<"\n";
}
void solve(){
	cin>>n>>X0>>Y0>>d>>t;
	vector<double> l,r;
	for(int i=0;i<n;i++){
		cin>>p[i].x>>p[i].y;
		double a=atan2(p[i].y,p[i].x);
		double b=atan2(sqrt(p[i].x*p[i].x+p[i].y*p[i].y-d*d),d);
		l.push_back(change(a+b));
		r.push_back(change(a-b));
	}
	sort(l.begin(),l.end());
	sort(r.begin(),r.end());
	double S,T;
	if(check(l[0],1))
		T=l[0];
	else
		T=l[n-1];
	if(check(r[0],-1))
		S=r[0];
	else
		S=r[n-1];
//	cout<<L<<" "<<R<<"\n";
//	print(L);print(R);
	double th0=atan2(Y0,X0),ans=0;
	S-=th0;T-=th0;
	double C=T-S;
	while(t>=2*pi){
		ans+=C;
		t-=pi*2;
	}
	if(S<T){
		ans+=inter(0,t,S,T);
	}
	else{
		ans+=inter(0,t,0,T);
		ans+=inter(0,t,S,pi*2);
	}
	cout<<fixed<<setprecision(12)<<ans<<"\n";
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie();cout.tie();
//	int T;cin>>T;
//	while(T--)
		solve();
	return 0;
}
/*
3 1 0 1 10000
1 2
2 1
2 2
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4272kb

input:

3 1 0 1 1
1 2
2 1
2 2

output:

1.000000000000

result:

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

Test #2:

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

input:

3 1 0 1 2
1 2
2 1
2 2

output:

1.570796326795

result:

ok found '1.5707963', expected '1.5707963', error '0.0000000'

Test #3:

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

input:

3 1 0 1 10000
1 2
2 1
2 2

output:

2500.707752257475

result:

ok found '2500.7077523', expected '2500.7077523', error '0.0000000'

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 4172kb

input:

3 10000 10000 1 10000
10000 9999
10000 10000
9999 10000

output:

-4997.087356834856

result:

wrong answer 1st numbers differ - expected: '0.3842413', found: '-4997.0873568', error = '4997.4715981'