QOJ.ac

QOJ

ID提交记录ID题目HackerOwner结果提交时间测评时间
#1282#814871#9869. Horizon Scanningucup-team3474ucup-team3474Failed.2024-12-14 21:56:322024-12-14 21:56:34

详细

Extra Test:

Accepted
time: 114ms
memory: 46344kb

input:

1
200000 133279
-999999996 999920522
-999999991 -999974599
-999999986 999952329
-999999963 999931868
-999999950 -999982653
-999999950 999967365
-999999933 999985991
-999999932 999959102
-999999923 999965258
-999999885 999930344
-999999877 999920137
-999999876 999926127
-999999852 999931355
-99999983...

output:

6.283163941301425

result:

ok found '6.2831639', expected '6.2831639', error '0.0000000'

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#814871#9869. Horizon Scanningucup-team3474AC ✓117ms44828kbC++202.1kb2024-12-14 21:46:132024-12-14 21:46:14

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PII;

const int N=5e5+10,mod=998244353;
const double PI=acos(-1);
int n,m,k,l,b;
typedef struct{
    ll x,y,cnt;
    double jiao;
    ll fz,fm,flag;
}Node;

PII cal(ll x,ll y){
    if(x==0&&y==0) return {0,0};
    else if(x==0){
        if(y>0)
        return {0,1};
        else return {0,-1};
    } 
    else if(y==0){
        if(x>0)
        return {1,0};
        else return {-1,0};
    }else{
        ll gg=__gcd(abs(x),abs(y));
        x/=gg,y/=gg;
        return {x,y};
    }
}

bool cmp(Node &a,Node &b){
    return a.jiao<b.jiao;
}


void __(){
    cin>>n>>m;
    vector<Node> nd;
    map<PII,int> mp;
    for(int i=1;i<=n;i++){
        ll x,y;
        scanf("%lld%lld",&x,&y);
        PII res=cal(x,y);
        mp[res]++;
    }
    int sz=mp.size();
    for(auto [x,y]:mp){

        Node nnd;
        nnd.fz=nnd.x=x.first;
        nnd.fm=nnd.y=x.second;
        nnd.cnt=y;
        double u=x.first,v=sqrtl(x.first*x.first+x.second*x.second);
        if(x.second>0) nnd.jiao=acos(u/v);
        else nnd.jiao=PI*2-acos(u/v);
        nd.push_back(nnd);
        // nd.push_back({x.first,x.second})
    }
    
    for(int i=0;i<sz;i++){
        nd.push_back(nd[i]);
    } 
    for(int i=0;i<sz;i++){
        nd[i+sz].jiao+=PI*2;
    }
    sort(nd.begin(),nd.end(),cmp);
    // for(auto x:nd) cout<<x.jiao<<" "<<x.cnt<<endl;;
    // cout<<endl;
    int j=0,tot=0;
    double ans=0;
    for(int i=0;i<sz;i++){
        // cout<<j<<" "<<tot<<" "<<m+nd[i].cnt<<endl;
        while(j<=i+sz&&tot<m+nd[i].cnt){
            tot+=nd[j].cnt;
            j++;
        }
        // cout<<j<<" "<<tot<<endl;
        ans=max(ans,nd[j-1].jiao-nd[i].jiao);
        tot-=nd[i].cnt;
    }
    printf("%.15f\n",ans);
}



//246748500000

int main(){
    
    // ios::sync_with_stdio(0);
    // cin.tie(0);
    // mi[0]=1;
    // for(int i=1;i<=20;i++) mi[i]=mi[i-1]*3;
    int _=1;
    cin>>_;
    
    for(int i=1;i<=_;i++){
        
        __();
        
    }
    // int x;
    
}