QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#822234 | #9869. Horizon Scanning | LeoG | AC ✓ | 197ms | 15164kb | C++23 | 3.6kb | 2024-12-20 02:35:33 | 2024-12-20 02:35:33 |
Judging History
answer
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#define ll long long
#define all(v) v.begin(),v.end()
#define ld long double
#define pll std::pair<ll,ll>
#define pi std::pair<int,int>
#define vi std::vector<int>
#define vll std::vector<ll>
#define len(x) (int)x.size()
#define vec(T) std::vector<T>
#define PI (ld)3.14159265358979323846
// overload << for pair
template <typename T>
std::ostream& operator<<(std::ostream& os, const std::pair<T, T>& pair) {
std::cout << "(" << pair.first << ", " << pair.second << ")";
return os;
}
// overload << for vec
template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
os << "[";
for (size_t i = 0; i < vec.size(); ++i) {
os << vec[i] << (i == vec.size() - 1 ? "\0" : ", ");
}
os << "]";
return os;
}
// overload << for map and unordered_map Output
template<typename Map>
void printMap(const Map& m) {
std::cout << '{';
for (auto it = m.begin(); it != m.end(); it++) {
std::cout << it -> first << ": " << it -> second << (std::next(it) == m.end() ? "\0" : ", ");
}
std::cout << "}";
}
template <typename K, typename V>
std::ostream& operator<<(std::ostream& os, const std::map<K, V>& m) {
printMap(m);
return os;
}
template <typename K, typename V>
std::ostream& operator<<(std::ostream& os, const std::unordered_map<K, V>& m) {
printMap(m);
return os;
}
// overload << for set and unordered_set Output
template<typename Set>
void printSet(const Set& s) {
std::cout << '{';
for (auto it = s.begin(); it != s.end(); it++) {
std::cout << *it << (std::next(it) == s.end() ? "\0" : ", ");
}
std::cout << "}";
}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& s) {
printSet(s);
return os;
}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::unordered_set<T>& s) {
printSet(s);
return os;
}
// General print function
template <typename T>
void print(const T& val) {
std::cout << val << std::endl;
}
// Variadic template print function
template<typename T, typename... Args>
void print(const T& t, const Args&... args) {
std::cout << t << ' ';
print(args...);
if (sizeof...(args) == 1) std::cout << '\n';
}
void solve(){
int n, k;
std::cin >> n >> k;
int x, y;
vec(ld) the(n), tmp(n);
for (int i = 0; i < n; i++){
std::cin >> x >> y;
the[i] = atan2(y, x);
tmp[i] = the[i] + 2 * PI;
}
std::sort(all(the));
std::sort(all(tmp));
the.insert(the.end(), all(tmp));
ld mx = 1e9;
ll l = 0, r = 7 * mx;
auto check = [&](ll m) {
ld a = m / mx;
int j = 0;
for (int i = 0; i < n; i++) {
while (the[j] - the[i] <= a) {
j++;
}
if (j - i <= k) return false;
}
return true;
};
while (l < r) {
ll m = (l + r) / 2;
if (check(m)) {
r = m;
} else {
l = m + 1;
}
}
std::cout << std::fixed << std::setprecision(9) << l / mx << '\n';
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t = 1;
std::cin >> t;
while (t--) solve();
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4304kb
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.283185308 1.570796327 5.497787144 3.141592655 3.141592654
result:
ok 5 numbers
Test #2:
score: 0
Accepted
time: 55ms
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.692991498 2.574863437 4.652758268 2.772633108 5.742765807 4.857698992 3.419892313 2.812799963 6.283185308 6.283185308 5.117280767 6.146782703 3.842089024 2.342496717 3.463343208 6.283185308 5.961434753 3.324703471 5.262774929 5.672459343 1.673877936 1.114190855 2.408777552 6.283185308 5.355890090 ...
result:
ok 10000 numbers
Test #3:
score: 0
Accepted
time: 55ms
memory: 4144kb
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.926990817 6.283185308 3.360261600 2.677945045 3.770388941 1.762584469 3.840252479 5.497787144 2.034443936 1.815774990 4.347187531 6.141288253 5.176036590 5.465540262 5.769039152 4.366253017 5.994755749 4.892242481 4.171969481 5.677640644 5.961434753 3.506794104 4.542975937 5.300391584 4.493720035 ...
result:
ok 10000 numbers
Test #4:
score: 0
Accepted
time: 55ms
memory: 4244kb
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.909784541 1.975688114 1.986860833 3.926990817 3.697758884 6.283185308 6.141288253 6.193871315 5.805354253 6.252891548 5.728877811 3.090091843 1.892546882 5.634189749 2.896613991 6.283185308 2.914793806 6.147657594 1.951302704 5.564355308 5.497787144 3.098141759 4.390638426 3.909448757 2.641523911 ...
result:
ok 10000 numbers
Test #5:
score: 0
Accepted
time: 50ms
memory: 4236kb
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.239319561 5.275705242 5.300391584 5.387129923 5.888394188 4.117319357 1.138388552 1.515297822 6.147657594 6.158830313 2.574863437 5.940161367 1.608514280 4.609945127 5.071159651 4.234557926 3.790588213 4.037648039 3.916002249 1.063697823 4.280988254 5.857255651 3.407844703 5.421015253 2.956244704 ...
result:
ok 10000 numbers
Test #6:
score: 0
Accepted
time: 50ms
memory: 4120kb
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.137875297 6.283185308 6.118036630 3.200348477 2.653756215 6.253782019 3.605240263 3.559816984 1.509146157 5.927549423 6.258799899 2.622446540 4.393833304 5.497787144 4.248741372 5.497787144 4.629247749 3.546484440 6.004885649 1.196751896 2.885441272 6.200044076 1.923786715 5.662935822 5.742765807 ...
result:
ok 10000 numbers
Test #7:
score: 0
Accepted
time: 55ms
memory: 4240kb
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.271309398 6.283185308 5.222514721 6.003065704 3.925872136 5.546528996 3.210314924 3.039930050 4.227531782 3.032019666 2.191215234 3.039008091 4.331327151 6.283185308 5.110002266 2.946314027 5.176036590 5.699183572 2.061179866 6.283185308 2.227889786 6.170774862 6.283185308 6.283185308 6.282339999 ...
result:
ok 10000 numbers
Test #8:
score: 0
Accepted
time: 57ms
memory: 4348kb
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 -...
output:
3.589112629 2.979755223 0.283794110 2.035027707 4.887981143 1.004067110 4.745709977 5.325596330 4.310274965 5.603383680 1.579805093 4.329645471 5.547222097 1.460139106 1.531044552 2.871674932 2.632578967 3.124050594 0.680521225 5.420165636 4.778957145 2.403035204 4.279981205 4.678503651 4.003762709 ...
result:
ok 100 numbers
Test #9:
score: 0
Accepted
time: 75ms
memory: 4756kb
input:
20 9045 8319 -1000 -986 -1000 -683 -1000 -430 -1000 -292 -1000 53 -1000 667 -999 -855 -999 -350 -999 -174 -999 -51 -999 -43 -999 235 -999 465 -999 530 -998 -997 -998 -311 -998 21 -998 44 -998 182 -997 -313 -997 -195 -997 -13 -997 412 -997 425 -996 -542 -996 -348 -996 -126 -996 -59 -996 -40 -996 84 -...
output:
5.911511004 3.743868516 2.538482859 2.159967359 4.295037710 4.771674475 4.682407813 5.078984395 1.600801822 3.340402546 3.368792529 2.113016029 4.855399411 4.324001054 0.107853562 0.179821125 5.376654761 4.449566024 4.394401666 2.938184873
result:
ok 20 numbers
Test #10:
score: 0
Accepted
time: 88ms
memory: 13792kb
input:
1 166347 18723 -1000 -979 -1000 -975 -1000 -928 -1000 -914 -1000 -898 -1000 -889 -1000 -876 -1000 -873 -1000 -858 -1000 -840 -1000 -838 -1000 -801 -1000 -783 -1000 -744 -1000 -738 -1000 -733 -1000 -713 -1000 -712 -1000 -695 -1000 -689 -1000 -680 -1000 -675 -1000 -671 -1000 -646 -1000 -643 -1000 -608...
output:
0.851449179
result:
ok found '0.8514492', expected '0.8514492', error '0.0000000'
Test #11:
score: 0
Accepted
time: 96ms
memory: 13288kb
input:
1 154903 84960 -1000 -979 -1000 -965 -1000 -956 -1000 -945 -1000 -920 -1000 -901 -1000 -878 -1000 -860 -1000 -858 -1000 -709 -1000 -693 -1000 -648 -1000 -619 -1000 -602 -1000 -579 -1000 -474 -1000 -473 -1000 -454 -1000 -443 -1000 -427 -1000 -407 -1000 -403 -1000 -384 -1000 -351 -1000 -279 -1000 -244...
output:
3.538926686
result:
ok found '3.5389267', expected '3.5389267', error '0.0000000'
Test #12:
score: 0
Accepted
time: 92ms
memory: 13236kb
input:
1 158037 96343 -1000 -1000 -1000 -905 -1000 -881 -1000 -833 -1000 -804 -1000 -803 -1000 -782 -1000 -775 -1000 -765 -1000 -759 -1000 -756 -1000 -748 -1000 -722 -1000 -674 -1000 -669 -1000 -630 -1000 -610 -1000 -573 -1000 -443 -1000 -411 -1000 -409 -1000 -403 -1000 -388 -1000 -366 -1000 -349 -1000 -33...
output:
3.972028779
result:
ok found '3.9720288', expected '3.9720288', error '0.0000000'
Test #13:
score: 0
Accepted
time: 64ms
memory: 4256kb
input:
10000 17 12 -853202371 684059854 -659446544 -924219854 -418025687 117998679 -399757126 -365708913 -331597239 -270896799 -204989763 869548983 -118492298 963842298 -77481232 672198731 45930201 -58234380 52605147 -900097542 78371985 940503934 235210685 595759114 391284089 234315077 416229789 -827244230...
output:
5.398525111 5.373907875 1.173578173 1.544365260 3.778288650 3.570471587 6.282974859 5.095925203 2.987578247 2.305566506 3.390784165 5.785473239 4.810963613 0.956757419 4.629431731 4.799508063 4.170288906 5.739477697 6.121029448 3.567468293 6.228064725 6.282567575 4.014654559 0.900429824 3.994365188 ...
result:
ok 10000 numbers
Test #14:
score: 0
Accepted
time: 61ms
memory: 4140kb
input:
1000 133 108 -994106086 710243426 -991027749 -548437545 -983318226 -917527783 -943673956 -368162275 -935819096 616077188 -928022346 487569673 -924213856 -369318351 -914827619 426646545 -883935180 590882141 -870015071 -270471333 -834927107 -211343853 -829266515 354007200 -788041913 -60481736 -7822837...
output:
5.742801793 1.915364240 3.804345799 1.791916271 3.169520671 6.078646215 3.786067460 3.665969073 6.226583453 5.902152193 5.944315710 0.715167688 3.831574253 1.222845719 2.598426467 5.547328921 4.079194743 0.704220994 5.857822427 0.689485448 0.937982153 1.421522699 4.271326280 3.118995097 6.180969179 ...
result:
ok 1000 numbers
Test #15:
score: 0
Accepted
time: 67ms
memory: 4336kb
input:
100 1367 924 -999416811 990355566 -997656126 346133696 -997071616 -657387469 -996176051 12622726 -995720693 334093112 -995478093 891631278 -994503890 341858449 -994297596 499383911 -993234202 533518057 -991636838 -4170504 -990563582 -407186200 -989454027 653116272 -989132124 -780605454 -988073521 -1...
output:
4.505153491 2.712558933 5.839678581 6.022977112 0.461606044 0.986991234 1.321970849 1.925841746 5.508608354 4.646355332 2.287677411 2.184872588 4.809409192 0.477078991 0.556341606 1.093619165 5.182714554 3.113184662 4.380233956 2.749259283 2.791795335 6.271733358 5.753875046 2.900718882 2.639327935 ...
result:
ok 100 numbers
Test #16:
score: 0
Accepted
time: 93ms
memory: 5240kb
input:
10 13806 4955 -999669776 933068103 -999542354 721337508 -999499427 357140594 -999429088 -925180511 -999334813 -145726169 -999291694 -886327684 -999281647 811188099 -999145269 860687107 -998961821 -979442436 -998769313 446186367 -998591455 658309173 -998539751 -569480843 -998479467 279850955 -9984754...
output:
2.417080469 6.161192230 3.960020377 3.994361793 2.551550837 0.522723837 4.097843828 6.210382664 5.981728030 0.777223686
result:
ok 10 numbers
Test #17:
score: 0
Accepted
time: 66ms
memory: 10608kb
input:
1 112596 94970 -999980219 399324466 -999932413 952114487 -999894556 -951211102 -999891030 -996222974 -999864824 412806264 -999853190 -269700371 -999845814 -23906803 -999841507 -459154880 -999825178 716247149 -999761774 -154047106 -999729655 -171480333 -999709604 -666447277 -999704754 -22442485 -9996...
output:
5.442593880
result:
ok found '5.4425939', expected '5.4425939', error '0.0000000'
Test #18:
score: 0
Accepted
time: 113ms
memory: 13476kb
input:
1 161568 13252 -999991243 -113889211 -999976572 -361096764 -999970140 -505012445 -999960654 600963873 -999959339 -269932510 -999956568 734634576 -999941447 716485764 -999940305 64397798 -999939982 746532931 -999939921 995002380 -999932747 185078659 -999927136 585216518 -999914684 898656539 -99990452...
output:
0.642474591
result:
ok found '0.6424746', expected '0.6424746', error '0.0000000'
Test #19:
score: 0
Accepted
time: 136ms
memory: 15164kb
input:
1 186192 126483 -999998234 974001047 -999976292 -133179660 -999967957 112862981 -999957851 70030467 -999951528 743907713 -999931316 66002112 -999907988 888991267 -999905412 470798211 -999903986 -103943462 -999900422 255729004 -999898174 917068198 -999884392 -183592605 -999880179 -650076162 -99987469...
output:
4.401245685
result:
ok found '4.4012457', expected '4.4012457', error '0.0000000'
Test #20:
score: 0
Accepted
time: 40ms
memory: 4120kb
input:
1000 133 9 -10 -839744900 -10 -620593257 -10 -322048342 -10 578093727 -10 898998949 -9 -833794004 -9 -704882916 -9 -570204575 -9 -506146571 -9 -109555290 -9 309734100 -9 396668416 -8 -928874025 -8 376566668 -8 596463598 -8 600491164 -8 894775141 -7 -281322833 -7 49984651 -7 154512939 -7 205573228 -7...
output:
3.141592583 6.283185249 3.141592615 3.141591175 6.283185271 6.283185296 3.141592650 6.283185304 3.141592641 6.283185251 6.283185282 3.141592760 3.141592646 3.141592624 3.141592616 6.283185274 3.141592650 3.141592654 3.141592654 6.283185305 6.283185203 3.141592660 3.141592651 3.141592621 3.141592654 ...
result:
ok 1000 numbers
Test #21:
score: 0
Accepted
time: 62ms
memory: 6704kb
input:
5 23120 8224 -10 -999575056 -10 -997485895 -10 -995458183 -10 -986953157 -10 -985268102 -10 -983223383 -10 -980910524 -10 -980404283 -10 -973605147 -10 -972441960 -10 -972440422 -10 -969122114 -10 -965754004 -10 -964812113 -10 -964558462 -10 -963159275 -10 -962972564 -10 -962085557 -10 -961552443 -1...
output:
3.141592643 3.141592632 3.141592607 3.141592650 6.283185273
result:
ok 5 numbers
Test #22:
score: 0
Accepted
time: 197ms
memory: 9704kb
input:
1 99995 60000 1 100001 1 100002 1 100003 1 100004 1 100005 1 100006 1 100007 1 100008 1 100009 1 100010 1 100011 1 100012 1 100013 1 100014 1 100015 1 100016 1 100017 1 100018 1 100019 1 100020 1 100021 1 100022 1 100023 1 100024 1 100025 1 100026 1 100027 1 100028 1 100029 1 100030 1 100031 1 10003...
output:
6.283185307
result:
ok found '6.2831853', expected '6.2831853', error '0.0000000'
Extra Test:
score: 0
Extra Test Passed