QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#805448#9869. Horizon ScanningLittleXi#WA 28ms4348kbC++111.4kb2024-12-08 16:44:062024-12-08 16:44:07

Judging History

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

  • [2024-12-08 16:44:07]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:4348kb
  • [2024-12-08 16:44:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rof(i,a,b) for(int i=(a);i>=(b);i--)
#define db long double
#define ll long long
#define wln putchar('\n')
const int N=200005;
const db eps=1e-10,pi=acos(-1);
struct vec2{int x,y;}p[N*2];
ll operator *(vec2 a,vec2 b){return 1ll*a.x*b.x+1ll*a.y*b.y;}
ll operator /(vec2 a,vec2 b){return 1ll*a.x*b.y-1ll*a.y*b.x;}
db abs(vec2 a){return sqrt((db)(1ll*a.x*a.x+1ll*a.y*a.y));}
int xx(vec2 a)
{
    if(a.x>0&&a.y>=0)return 1;
    if(a.x<=0&&a.y>0)return 2;
    if(a.x<0&&a.y<=0)return 3;
    if(a.x>=0&&a.y<0)return 4;
    return 0;
}
bool cmp(vec2 a,vec2 b)
{
    int xa=xx(a),xb=xx(b);
    if(xa!=xb)return xa<xb;
    return a/b>0;
}
db angle_between(vec2 a,vec2 b)
{
    db t1=atan2(a.y,a.x),t2=atan2(b.y,b.x);
    db t=t2-t1;
    if(t<-eps)t+=2*pi;
    return t;
}
int n,k;
void Main()
{
    scanf("%d%d",&n,&k);
    For(i,1,n)scanf("%d%d",&p[i].x,&p[i].y);
    if(k>=n-1){printf("%.7Lf\n",2*pi); return;}
    sort(p+1,p+n+1,cmp);
    copy(p+1,p+n+1,p+n+1);
    // For(i,1,n)printf("(%d,%d)",p[i].x,p[i].y); wln;
    db ans=0;
    For(i,1,n)
    {
        db t=angle_between(p[i],p[i+k]);
        if(abs(t)<eps&&(i-1)%n>(i+k-1)%n)t+=2*pi;
        ans=max(ans,t);
    }
    printf("%.7Lf\n",ans);
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)Main();
}

詳細信息

Test #1:

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

input:

5
1 1
0 1
8 2
1 0
1 1
0 1
-1 1
-1 0
-1 -1
0 -1
1 -1
4 2
-1 1
0 1
0 2
1 1
4 2
-1000000000 0
-998244353 1
998244353 1
1000000000 0
3 1
0 1
0 2
0 -1

output:

6.2831853
1.5707963
5.4977871
3.1415927
3.1415927

result:

ok 5 numbers

Test #2:

score: -100
Wrong Answer
time: 28ms
memory: 4272kb

input:

10000
16 1
-10 -6
-5 -6
-4 9
-2 5
-2 10
1 -7
1 -5
1 6
3 1
4 -9
6 -10
6 -3
6 1
8 -5
8 -4
9 -4
17 4
-9 2
-8 -4
-8 -3
-8 -1
-6 -2
-6 -1
-6 8
-5 -8
-5 10
-4 8
-2 -8
4 -9
4 0
5 -3
8 -5
9 -2
10 10
10 6
-7 2
-4 6
-2 -7
-2 -1
-1 7
1 -9
1 8
3 -4
7 -4
9 -2
14 3
-9 10
-8 -10
-8 -8
-6 -7
-6 -5
-1 -7
-1 -2
0 -1
...

output:

1.6929915
2.5748634
4.6527583
2.7726331
5.7427658
4.8576990
3.4198923
2.8128000
6.2831853
6.2831853
5.1172808
6.2831853
3.8420890
2.3424967
3.4633432
6.2831853
5.9614348
3.3247035
5.2627749
5.6724593
1.6738779
1.1141909
2.4087776
6.2831853
5.3558901
3.7998606
4.1932429
4.0513458
4.5342960
4.3612351
...

result:

wrong answer 12th numbers differ - expected: '6.1467827', found: '6.2831853', error = '0.0221909'