QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#884206 | #9576. Ordainer of Inexorable Judgment | wangjinbo | WA | 1ms | 4096kb | C++20 | 2.3kb | 2025-02-05 22:07:50 | 2025-02-05 22:07:52 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#define y0 M_y0
using namespace std;
typedef long long ll;
const int N=105,M=5e6+10;
const double PI=acos(-1);
int n,x0,y0,d,t;
int x[N],y[N],num;
struct node{
double x;
int op;
}a[M];
bool operator < (node x,node y){
return x.x<y.x;
}
double mx=0.0,mn=1e18;
void add(double l,double r){
a[++num]=(node){l,1};
a[++num]=(node){r,-1};
}
void solve(double tx,double ty){
double ang=atan2(ty,tx);if(ang<0)ang+=2*PI;
if(d>=sqrt(tx*tx+ty*ty)){
add(0,2*PI);
return;
}
double del=asin(d/sqrt(tx*tx+ty*ty));
double tl=ang-del,tr=ang+del;
if(tl<0){
add(0,tl+2*PI);add(tr,2*PI);
}
else if(tr>2*PI){
add(0,tr-2*PI);add(tl,2*PI);
}
else{
add(tl,tr);
}
}
inline ll read(){
ll x=0,w=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}
while('0'<=c&&c<='9')x=x*10+c-'0',c=getchar();
return x*w;
}
int main(){
n=read();x0=read();y0=read();d=read();t=read();
for(int i=1;i<=n;i++)x[i]=read(),y[i]=read();
x[n+1]=x[1];y[n+1]=y[1];
for(int i=1;i<=n;i++){
solve(x[i],y[i]);
if(x[i]==x[i+1]){
for(int ty=min(y[i],y[i+1])+1;ty<max(y[i],y[i+1]);ty++)solve(x[i],ty);
}
else{
double k=(y[i+1]-y[i])/(x[i+1]-x[i]);
for(int tx=min(x[i],x[i+1])+1;tx<max(x[i],x[i+1]);tx++){
double ty=y[i]+k*(tx-x[i]);solve(tx,ty);
}
}
}
double ans=0.0;
int cnt=0;
double a0=atan2(y0,x0);
int w=t/(2*PI);double ls=t-2*PI*w;
a[++num]=(node){a0,0};
if(a0+ls>2*PI)a[++num]=(node){a0+ls-2*PI,0};
else a[++num]=(node){a0+ls,0};
sort(a+1,a+1+num);
for(int i=1;i<=num;i++){
if(cnt>0&&i>1){
int cw=w;
double cx=(a[i].x+a[i-1].x)/2.0;
if(a0+ls<=2*PI){
if(a0<=cx&&cx<=a0+ls)cw++;
}
else{
if(cx>=a0||cx<=a0+ls-2*PI)cw++;
}
ans+=cw*(a[i].x-a[i-1].x);
}
cnt+=a[i].op;
}
printf("%.12f\n",ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 4096kb
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: 1ms
memory: 4096kb
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: 3968kb
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: 0
Accepted
time: 0ms
memory: 3968kb
input:
3 10000 10000 1 10000 10000 9999 10000 10000 9999 10000
output:
0.384241300290
result:
ok found '0.3842413', expected '0.3842413', error '0.0000000'
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 4096kb
input:
3 -10000 -10000 10000 10000 -10000 -9999 -10000 -10000 -9999 -10000
output:
2499.455171841211
result:
wrong answer 1st numbers differ - expected: '2500.2406700', found: '2499.4551718', error = '0.0003142'