QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#801933 | #9869. Horizon Scanning | ucup-team5657# | TL | 348ms | 6512kb | C++20 | 2.0kb | 2024-12-07 10:49:33 | 2024-12-07 10:49:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define _rep(i_,a_,b_) for(int i_ = (a_); i_ <= (b_); ++i_)
#define mid ((L+R) / 2)
#define multiCase() int testCnt = in(); _rep(curCase,1,testCnt)
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
using ll = long long;
using pii = pair<int,int>;
int in(void) { int x; scanf("%d", &x); return x; } ll inl(void) { ll x; scanf("%lld", &x); return x; }
void out(int x) { printf("%d ", x); } void outln(int x) { printf("%d\n", x); }
void out(ll x) { printf("%lld ", x); } void outln(ll x) { printf("%lld\n", x); }
template<typename T> void chkmax(T &a, const T &b) { a = max(a, b); }
template<typename T> void chkmin(T &a, const T &b) { a = min(a, b); }
const int kN = 205000;
const double eps = 1e-8, pi = acos(-1);
int n, k;
double A[kN];
int tag[kN << 1];
int main() {
multiCase() {
n = in(), k = in();
_rep(i,1,n) {
int x = in(), y = in();
A[i] = atan2(y, x);
debug("%.5lf\n", A[i]);
}
double L = 0, R = pi, ans = 0;
_rep(i,1,60) {
debug("mid = %.5lf\n", mid);
vector<double> d = {-pi, pi};
_rep(i,1,n) {
if(A[i] - mid >= -pi) d.emplace_back(A[i] - mid);
else d.emplace_back(pi - (-pi - (A[i] - mid)));
if(A[i] + mid <= pi) d.emplace_back(A[i] + mid);
else d.emplace_back(-pi + (A[i] + mid - pi));
}
sort(d.begin(), d.end()), d.erase(unique(d.begin(), d.end()), d.end());
auto locate = [&](double x) { return lower_bound(d.begin(), d.end(), x) - d.begin(); };
int mn = n, cur = 0;
_rep(i,1,n) {
if(A[i] - mid >= -pi) tag[locate(A[i] - mid)]++;
else tag[0]++, tag[locate(pi - (-pi - (A[i] - mid)))]++;
if(A[i] + mid <= pi) tag[locate(A[i] + mid)]--;
else tag[0]++, tag[locate(-pi + (A[i] + mid - pi))]--;
}
int m = d.size();
_rep(i,0,m - 2) {
cur += tag[i]; chkmin(mn, cur);
}
_rep(i,0,m) tag[i] = 0;
if(mn >= k) R = mid; else L = mid;
}
printf("%.10lf\n", L * 2);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6288kb
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.2831853072 1.5707963268 5.4977871438 3.1415926546 3.1415926536
result:
ok 5 numbers
Test #2:
score: 0
Accepted
time: 341ms
memory: 4236kb
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.6929914975 2.5748634361 4.6527582673 2.7726331074 5.7427658069 4.8576989910 3.4198923126 2.8127999621 6.2831853072 6.2831853072 5.1172807667 6.1467827028 3.8420890235 2.3424967168 3.4633432080 6.2831853072 5.9614347528 3.3247034709 5.2627749281 5.6724593428 1.6738779353 1.1141908549 2.4087775518 6...
result:
ok 10000 numbers
Test #3:
score: 0
Accepted
time: 347ms
memory: 6252kb
input:
10000 19 7 -10 -6 -10 5 -3 0 -2 -5 -1 1 -1 6 0 3 0 7 1 9 3 -3 3 3 3 8 4 -1 5 8 6 -3 7 -5 7 4 8 10 9 -5 15 15 -9 -1 -8 6 -7 9 -6 -3 -4 -9 -1 -3 -1 8 1 -8 1 -7 3 -2 3 1 6 -9 7 -10 7 0 10 -9 10 3 -7 -1 -6 -2 -6 10 -5 2 -4 2 -3 -7 -2 -9 1 -3 3 4 7 7 15 4 -8 -8 -8 8 -7 0 -7 10 -6 -7 -5 6 -1 -3 -1 0 1 -2 ...
output:
3.9269908170 6.2831853072 3.3602615995 2.6779450446 3.7703889400 1.7625844688 3.8402524783 5.4977871438 2.0344439358 1.8157749899 4.3471875306 6.1412882526 5.1760365894 5.4655402613 5.7690391513 4.3662530168 5.9947557487 4.8922424802 4.1719694801 5.6776406436 5.9614347528 3.5067941034 4.5429759365 5...
result:
ok 10000 numbers
Test #4:
score: 0
Accepted
time: 348ms
memory: 6512kb
input:
10000 18 12 -10 -4 -10 7 -8 -10 -7 -4 -6 5 -6 7 -5 0 -2 -7 -1 2 -1 10 0 2 1 1 3 -2 5 3 5 5 6 -3 8 -3 9 -2 10 1 -10 -9 -7 -7 -5 2 -4 -7 -3 1 3 1 3 3 5 -4 9 2 9 6 11 2 -8 1 -8 6 -7 -2 -6 0 -5 0 -1 -9 2 -8 3 5 6 0 10 -2 10 6 20 9 -10 -6 -10 6 -9 -8 -7 5 -6 -4 -4 -8 -2 -10 -2 -3 -2 4 -1 1 2 -5 3 -2 5 -6...
output:
4.9097845402 1.9756881131 1.9868608325 3.9269908170 3.6977588837 6.2831853072 6.1412882526 6.1938713142 5.8053542522 6.2528915473 5.7288778110 3.0900918426 1.8925468812 5.6341897482 2.8966139905 6.2831853072 2.9147938055 6.1476575932 1.9513027039 5.5643553076 5.4977871438 3.0981417582 4.3906384260 3...
result:
ok 10000 numbers
Test #5:
score: 0
Accepted
time: 343ms
memory: 6288kb
input:
10000 19 7 -10 -1 -8 2 -7 -10 -6 6 -4 7 -3 -5 -3 1 -3 8 -2 4 -1 -7 0 -8 0 9 1 -10 2 1 2 3 3 5 6 -4 10 2 10 3 14 10 -8 2 -6 0 -5 -10 -5 10 -4 7 -3 -6 -2 -6 1 4 1 6 2 -1 3 -6 8 -4 9 -10 10 -1 12 8 -9 5 -7 2 -4 2 0 -2 0 5 1 6 3 2 4 9 5 5 7 -6 9 -9 9 2 19 12 -10 -10 -10 2 -9 -6 -8 2 -7 -5 -6 8 -4 1 -1 -...
output:
3.2393195609 5.2757052419 5.3003915839 5.3871299226 5.8883941875 4.1173193567 1.1383885512 1.5152978215 6.1476575932 6.1588303126 2.5748634361 5.9401613668 1.6085142793 4.6099451269 5.0711596507 4.2345579254 3.7905882126 4.0376480382 3.9160022483 1.0636978224 4.2809882538 5.8572556506 3.4078447027 5...
result:
ok 10000 numbers
Test #6:
score: 0
Accepted
time: 339ms
memory: 4112kb
input:
10000 11 10 -10 -1 -9 4 -9 10 -7 -7 -5 4 -4 -1 -2 -10 0 -7 0 5 3 3 3 5 12 12 -9 6 -9 8 -3 -2 -2 2 0 -4 1 0 2 -3 3 5 5 -2 7 -1 10 3 10 9 14 12 -10 0 -9 -3 -9 1 -9 10 -8 -1 -8 7 -6 -1 -1 -6 -1 2 1 -1 3 -7 4 9 9 -3 10 1 10 4 -9 -3 -7 -1 -6 -10 -3 -2 -3 7 2 -2 2 3 5 2 6 9 9 6 10 2 -9 -9 -9 6 -8 3 -5 -9 ...
output:
6.1378752965 6.2831853072 6.1180366298 3.2003484763 2.6537562149 6.2537820190 3.6052402626 3.5598169832 1.5091461562 5.9275494229 6.2587998980 2.6224465393 4.3938333033 5.4977871438 4.2487413714 5.4977871438 4.6292477485 3.5464844399 6.0048856482 1.1967518953 2.8854412710 6.2000440753 1.9237867146 5...
result:
ok 10000 numbers
Test #7:
score: 0
Accepted
time: 340ms
memory: 6320kb
input:
10000 14 1 -100 13 -96 -31 -82 -92 -77 -98 -50 1 -14 -57 -14 -31 -11 64 -8 75 9 68 25 100 54 -36 59 13 93 31 19 19 -76 -39 -60 95 -51 18 -39 11 -21 -46 -6 -94 -5 83 -3 -34 -3 72 0 -55 3 79 14 17 23 -88 32 37 50 70 61 -5 62 -43 84 -100 97 -50 13 7 -99 -63 -68 -87 -24 62 -20 -18 -2 -66 7 -49 13 -21 15...
output:
1.2713093975 6.2831853072 5.2225147207 6.0030657036 3.9258721355 5.5465289951 3.2103149237 3.0399300499 4.2275317818 3.0320196657 2.1912152338 3.0390080904 4.3313271506 6.2831853072 5.1100022651 2.9463140261 5.1760365894 5.6991835714 2.0611798651 6.2831853072 2.2278897855 6.1707748616 6.2831853072 6...
result:
ok 10000 numbers
Test #8:
score: -100
Time Limit Exceeded
input:
100 1413 755 -30 -30 -30 -28 -30 -27 -30 -26 -30 -21 -30 -12 -30 -10 -30 -8 -30 -5 -30 -1 -30 2 -30 4 -30 7 -30 9 -30 17 -30 19 -30 20 -30 23 -30 24 -30 30 -29 -29 -29 -23 -29 -15 -29 0 -29 4 -29 5 -29 9 -29 10 -29 11 -29 12 -29 14 -29 16 -29 17 -29 22 -29 27 -29 28 -28 -28 -28 -25 -28 -23 -28 -22 -...