QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#804525 | #9869. Horizon Scanning | ucup-team1134# | WA | 114ms | 4156kb | C++23 | 1.9kb | 2024-12-07 23:35:00 | 2024-12-07 23:35:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvii vector<vector<pair<int,int>>>
#define vvll vector<vector<pair<ll,ll>>>
#define vst vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end())
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=15<<26;
const double pi=acos(-1);
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
int Q;cin>>Q;
while(Q--){
int N,K;cin>>N>>K;
vector<double> S;
for(int i=0;i<N;i++){
int a,b;cin>>a>>b;
double z=atan2(b,a);
S.pb(z-2*pi);
S.pb(z);
S.pb(z+2*pi);
}
sort(all(S));
double l=0,r=pi;
for(int q=0;q<60;q++){
double mid=(l+r)/2;
vector<pair<double,double>> T;
for(int i=0;i<2*N;i++){
double a=S[i],b=S[i+K-1];
if(b-a>mid*2) continue;
T.pb(mp(b-mid,a+mid));
}
bool ok=true;
double z=-pi;
for(auto [a,b]:T){
if(z<=pi&&z<a) ok=false;
chmax(z,b);
}
if(ok) r=mid;
else l=mid;
}
cout<<fixed<<setprecision(25)<<r*2<<"\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 4100kb
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.2831853071795862319959269 1.5707963267948965579989817 5.4977871437821379529964361 3.1415926545915517920093407 3.1415926535897931159979635
result:
ok 5 numbers
Test #2:
score: -100
Wrong Answer
time: 114ms
memory: 4156kb
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.0838970949836277402056339 2.5748634360662872033742588 4.6527582672535201524510740 2.7726331073839363128286095 0.0000000000000000054497945 4.8576989910203920430831204 3.4198923125949045598304110 2.8127999620848380679660750 0.0000000000000000054497945 0.0000000000000000054497945 5.117280766669773051...
result:
wrong answer 1st numbers differ - expected: '1.6929915', found: '1.0838971', error = '0.3597740'