QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#305084 | #7783. Military Maneuver | ucup-team2000 | TL | 4350ms | 4000kb | C++23 | 2.7kb | 2024-01-14 17:08:29 | 2024-01-14 17:08:30 |
Judging History
answer
#pragma GCC optimize("O3,unroll-loops")
#ifdef ONLINE_JUDGE
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#include <bits/stdc++.h>
// #define double long double
struct simpson {
double area(double l, double r, double fl, double fm, double fr) {
return (fl + 4 * fm + fr) * (r - l) / 6;
}
double solve(double (*f)(double), double l, double m, double r, double eps,
double fl, double fm, double fr, double a) {
double lm = (l + m) / 2, rm = (m + r) / 2;
double flm = f(lm), frm = f(rm);
double left = area(l, m, fl, flm, fm), right = area(m, r, fm, frm, fr);
if (fabs(left + right - a) <= 15 * eps)
return left + right + (left + right - a) / 15.0;
return solve(f, l, lm, m, eps / 2, fl, flm, fm, left) +
solve(f, m, rm, r, eps / 2, fm, frm, fr, right);
}
double solve(double (*f)(double), double l, double r, double eps) {
double m = (l + r) / 2;
double fl = f(l), fm = f(m), fr = f(r);
return solve(f, l, m, r, eps, fl, fm, fr, area(l, r, fl, fm, fr));
}
} _simpson;
const double EPS = 3E-8;
const int SIZE = 20;
const double PI = acos(-1);
long long XL, YL, XR, YR;
int N;
std::pair<long long, long long> P[3000];
double XX[3000];
double ff(double y) {
double val0 = XX[0] + (P[0].second - y) * (P[0].second - y);
double min = val0, max = val0;
for (int i = 1; i < N; ++i) {
double val = XX[i] + (P[i].second - y) * (P[i].second - y);
if (min > val) min = val;
if (max < val) max = val;
}
return max - min;
}
double f(double x) {
static int cnt = 0;
for (int i = 0; i < N; ++i)
XX[i] = P[i].first - x, XX[i] *= XX[i];
double area = 0;
for (int t = 0; t < SIZE; ++t) {
area += (YR - YL) * ff((YL * (t + .5) + YR * (SIZE - .5 - t)) / SIZE);
}
area /= SIZE;
double ret = _simpson.solve(ff, YL, YR, std::max(EPS, area * EPS) / (1ll << 12));
// printf("%d %.10lf %.10lf\n", ++cnt, x, ret);
return ret;
}
int main() {
scanf("%lld%lld%lld%lld", &XL, &YL, &XR, &YR);
// XL = YL = -10000, XR = YR = 10000;
scanf("%d", &N);
// N = 2000;
for (int i = 0; i < N; ++i) {
scanf("%lld%lld", &P[i].first, &P[i].second);
// X[i] = rand() % 20000 - 10000; Y[i] = rand() % 20000 - 10000;
}
std::sort(P, P + N);
double area = 0;
for (int t = 0; t < SIZE; ++t) {
area += (XR - XL) * f((XL * (t + .5) + XR * (SIZE - .5 - t)) / SIZE);
}
area /= SIZE;
printf("%.10lf\n", _simpson.solve(f, XL, XR, std::max(EPS, area * EPS)) *
PI / (XR - XL) / (YR - YL));
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3932kb
input:
0 0 2 2 2 3 1 1 3
output:
8.3775804096
result:
ok found '8.3775804', expected '8.3775804', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3940kb
input:
0 0 2 2 2 5 1 1 3
output:
37.6991118431
result:
ok found '37.6991118', expected '37.6991118', error '0.0000000'
Test #3:
score: 0
Accepted
time: 29ms
memory: 3984kb
input:
-2911 2151 336 5941 2000 -83 79 -94 47 48 -29 -47 64 84 75 -44 -86 -58 -11 -31 58 20 53 80 -19 -82 74 -60 -26 8 -68 -42 -61 -14 12 -58 -18 92 10 35 -26 71 64 76 89 -80 6 70 4 -96 -99 95 -80 -3 -22 71 -89 -75 17 -35 -82 -59 95 60 48 -74 50 -82 90 -26 5 -75 -31 -45 85 85 14 -70 -57 59 46 55 13 -23 60 ...
output:
6657168.0928513119
result:
ok found '6657168.0928513', expected '6657168.1428534', error '0.0000000'
Test #4:
score: 0
Accepted
time: 93ms
memory: 3940kb
input:
-3013 5287 7654 9132 2000 -19 49 -17 -35 64 68 48 -49 -72 -14 29 -93 -13 -8 -80 11 39 88 -31 82 68 -66 5 41 -74 -8 0 15 11 34 69 -12 15 -86 5 -78 -48 73 10 9 -2 8 81 52 41 -43 -45 -41 -23 60 -40 -45 -26 27 -32 73 8 -20 2 91 46 17 51 -66 -65 -32 37 -9 58 63 -14 -31 60 -56 -85 -22 9 -66 -7 -53 -21 40 ...
output:
10130702.6969146766
result:
ok found '10130702.6969147', expected '10130702.4940150', error '0.0000000'
Test #5:
score: 0
Accepted
time: 17ms
memory: 3944kb
input:
-5561 9559 6905 9930 2000 79 338 2 214 325 -193 -390 -157 -517 943 -759 970 449 901 -369 636 -661 -211 847 -558 223 -564 185 822 -656 -854 -991 -617 -422 -169 -63 -799 327 -911 -960 945 -948 831 -494 93 266 -299 139 -535 796 707 75 -146 10 566 72 -713 -132 -341 348 924 -739 -838 982 995 -445 500 -71...
output:
158891446.7153211832
result:
ok found '158891446.7153212', expected '158891446.6238778', error '0.0000000'
Test #6:
score: 0
Accepted
time: 914ms
memory: 3972kb
input:
-5245 -7558 1275 934 2000 -40 125 79 -30 49 13 -127 153 -151 -28 -82 -140 147 131 123 -105 -84 71 -49 -146 -140 82 57 172 -140 -32 -173 24 -55 -101 44 142 -68 -114 122 69 -137 66 19 199 31 109 -161 -66 63 -101 65 -114 166 -66 83 -162 60 70 -19 -134 15 161 -130 22 -130 50 8 -121 150 89 132 44 -131 -3...
output:
11172638.3202034216
result:
ok found '11172638.3202034', expected '11172638.2656236', error '0.0000000'
Test #7:
score: 0
Accepted
time: 17ms
memory: 3968kb
input:
-7167 6117 -3297 6866 2000 -346 -144 -227 169 -168 -373 -63 -227 -24 405 -232 -163 295 22 222 351 293 41 -335 260 -43 -426 -205 193 163 -284 -406 284 -202 -114 -339 -86 -413 17 -237 -394 -333 -145 -104 416 -478 -53 451 102 85 58 -124 -472 424 -88 394 243 -459 45 12 -490 -9 465 -159 -202 315 -272 -24...
output:
52361395.1715819761
result:
ok found '52361395.1715820', expected '52361392.5150275', error '0.0000001'
Test #8:
score: 0
Accepted
time: 1666ms
memory: 4000kb
input:
-6462 -5871 5937 5853 2000 386 236 -108 937 -722 354 -710 -475 462 613 -884 446 595 -675 168 394 -744 -551 761 -399 -688 258 -53 104 -614 -177 -273 -678 794 -15 224 -911 -146 -216 53 633 2 -664 202 -440 24 437 495 623 -297 682 -520 -48 598 720 -7 353 163 744 557 13 395 588 -157 -672 631 -705 -68 818...
output:
57605015.5359908268
result:
ok found '57605015.5359908', expected '57605018.8701164', error '0.0000001'
Test #9:
score: 0
Accepted
time: 45ms
memory: 3952kb
input:
792 4703 2923 5458 2000 7281 5289 -5154 2943 -8483 3113 9380 -576 -2191 -291 -8200 898 -192 4724 1161 441 34 3999 8544 3576 -5481 4273 -9792 9565 4854 1262 4254 -3376 -5778 9480 8631 -2225 7129 2187 5344 7740 2975 6174 -2919 -7172 7990 -5117 -6823 -7233 5020 5269 -9874 1051 8841 4586 -3612 -7483 644...
output:
1133083705.2161078453
result:
ok found '1133083705.2161078', expected '1133083681.5454702', error '0.0000000'
Test #10:
score: 0
Accepted
time: 14ms
memory: 3980kb
input:
-4075 7303 -1671 8073 2000 -10 305 -1105 -119 -238 205 -1206 -482 943 -89 -1578 223 -520 1158 21 1622 -621 -886 -163 -515 283 1802 36 -1410 213 -1921 -1539 -231 835 148 56 1448 -407 1653 1896 -533 1321 -437 530 172 132 18 1260 586 -363 -220 989 1353 281 -1907 -1116 -801 695 592 1221 -983 1731 -939 -...
output:
205950763.1642234623
result:
ok found '205950763.1642235', expected '205950762.7341621', error '0.0000000'
Test #11:
score: 0
Accepted
time: 54ms
memory: 3996kb
input:
2121 3865 3457 7582 2000 3902 -1511 -1817 504 -3515 3188 -4470 211 536 1795 2230 -1512 3979 297 2430 901 2368 2525 -2553 -252 476 2279 -3859 2565 -754 396 3358 2726 4787 -664 173 1056 -1154 -1556 -2442 -406 -1838 976 3785 1136 -131 -421 77 4058 3773 2965 1333 -622 4188 -2571 -624 -2051 -1965 4268 -1...
output:
399702016.0550903678
result:
ok found '399702016.0550904', expected '399702074.0540065', error '0.0000001'
Test #12:
score: 0
Accepted
time: 652ms
memory: 3996kb
input:
5377 -2525 9878 7241 2000 316 9854 1690 3184 -9795 -898 -7924 3181 -2410 1478 -3849 -8880 8447 -487 3826 -2478 1445 -2923 5459 677 8830 -3598 1045 -5139 7231 -6856 -4410 4982 -3180 -2528 -7891 -4137 6686 -3732 -6102 -1926 6562 5714 4562 -5710 223 -9921 2609 -3935 8187 55 -5017 -4465 -1387 -2695 6015...
output:
1061816937.1068747044
result:
ok found '1061816937.1068747', expected '1061816977.6676595', error '0.0000000'
Test #13:
score: 0
Accepted
time: 606ms
memory: 3908kb
input:
-3243 -8661 4122 -2937 2000 1 7637 0 1870 1 7982 -1 -391 0 -4347 -1 2035 0 -2623 0 6943 0 1511 0 -8789 -1 7213 1 -4998 1 -8958 1 -182 -1 -318 1 3712 0 -3215 1 -5210 1 6983 -1 -2567 1 -470 -1 7652 0 -2394 1 7196 1 280 1 5785 1 545 1 8779 1 1 1 -9675 1 5137 -1 -1160 1 -3955 0 3176 0 -6143 0 519 1 5678...
output:
791760943.5234919786
result:
ok found '791760943.5234920', expected '791760973.9585004', error '0.0000000'
Test #14:
score: 0
Accepted
time: 19ms
memory: 3992kb
input:
-4763 3483 5561 3747 2000 -3915 1 8391 -1 -4112 0 5453 -1 -8775 1 -2182 0 -3819 1 -2702 1 -7119 1 1279 0 7959 -1 -4345 0 -1024 1 -4853 -1 -2637 1 -2136 -1 -9603 -1 -5869 1 -1765 1 -3625 1 9255 0 4677 1 4660 -1 3250 1 -8156 -1 -2988 0 8492 1 -961 0 9331 -1 -1913 1 -3152 0 8877 -1 8390 0 3420 0 -7929 ...
output:
505361071.0875887871
result:
ok found '505361071.0875888', expected '505360943.9703766', error '0.0000003'
Test #15:
score: 0
Accepted
time: 209ms
memory: 3972kb
input:
-8627 -2766 -1956 4443 2000 -4 -9231 -6 -3132 4 176 1 8378 1 6264 -3 -9699 -10 -6369 -9 -4283 -7 7401 1 -1418 7 -5096 7 -7114 -4 -3937 2 5922 -1 6133 6 -8932 -6 3552 2 4767 9 7643 3 4129 4 2295 -5 8379 1 768 -10 -8915 5 4022 -6 -6665 4 4425 -3 6046 6 3827 -5 3831 -6 -6224 5 9807 9 11 5 4503 -6 -5911...
output:
448946373.9251971245
result:
ok found '448946373.9251971', expected '448946370.7927880', error '0.0000000'
Test #16:
score: 0
Accepted
time: 45ms
memory: 3932kb
input:
-4229 -9182 1776 -5186 2000 8444 3 3252 6 -7072 5 5793 -1 1339 2 -3500 6 -9676 -4 -1101 -8 -4997 7 462 -6 1476 7 -1331 9 561 -4 -951 -6 -466 -8 -8455 2 8033 -5 2982 9 -7803 6 8473 1 674 5 -7228 -1 -1891 -10 -3408 -7 -917 -8 9486 -5 355 9 1212 -4 3712 10 9106 1 9958 1 7446 -5 8816 -1 -1752 4 4285 0 -...
output:
438654071.0130849481
result:
ok found '438654071.0130849', expected '438654068.2184606', error '0.0000000'
Test #17:
score: 0
Accepted
time: 646ms
memory: 3940kb
input:
-6880 -3012 949 2588 2000 56 -2490 59 -8874 -90 7871 -48 9340 -29 -4546 72 1776 -22 -8437 -7 5228 6 -2206 89 -5714 71 -6149 44 8645 -17 -8800 19 -8446 -31 -1438 58 4422 -10 -6275 98 -7180 21 -3721 14 3061 -60 -2084 45 4628 -57 -7683 -19 -5389 97 4046 58 5141 -44 288 49 -3579 -39 -7224 94 5901 -68 -3...
output:
411858699.1149827242
result:
ok found '411858699.1149827', expected '411858700.0432993', error '0.0000000'
Test #18:
score: 0
Accepted
time: 151ms
memory: 3956kb
input:
2772 -6314 4903 4834 2000 -9330 45 1739 56 1062 -58 6549 -25 2178 88 -6106 -87 -6078 -75 -9429 58 2648 -27 -9516 52 9061 -9 -1775 -3 -6885 74 -4346 27 -1758 -95 -9196 87 -752 -98 1724 -24 825 8 -2431 18 -360 14 1472 52 8871 -71 7205 -39 -8033 -28 8724 8 -5197 -52 9320 -2 2849 -64 -968 -77 9867 100 3...
output:
605362227.3801751137
result:
ok found '605362227.3801751', expected '605362233.7529563', error '0.0000000'
Test #19:
score: 0
Accepted
time: 1082ms
memory: 3984kb
input:
-10000 -10000 10000 10000 2000 8592 4096 9271 1216 8596 5077 9077 1756 9059 3053 8744 4685 8509 4543 7828 4581 8975 2478 9394 2850 9194 3045 9532 1437 9290 1261 8175 4923 8485 4507 8166 4987 8578 4973 9548 2129 9018 3543 8136 5431 8830 2783 9636 2605 8589 2865 9617 1981 9427 1091 7817 5017 9129 1790...
output:
238108912.7037248611
result:
ok found '238108912.7037249', expected '238108908.6175798', error '0.0000000'
Test #20:
score: 0
Accepted
time: 1295ms
memory: 3984kb
input:
-10000 -10000 10000 10000 2000 6262 7501 9152 454 8076 5537 5939 7930 9638 2163 8615 4078 9554 1084 4352 8207 9578 1188 9456 406 8908 3352 5449 7414 8782 3668 8621 4472 9319 957 6598 6780 8818 2341 6747 7300 9941 555 7653 6219 9183 342 7768 5183 8604 4366 3084 8703 7005 6054 7108 6347 9604 498 9180 ...
output:
397620994.8123716116
result:
ok found '397620994.8123716', expected '397620990.0841421', error '0.0000000'
Test #21:
score: 0
Accepted
time: 1550ms
memory: 4000kb
input:
-10000 -10000 10000 10000 2000 1066 9157 9386 1781 6605 7086 2309 8912 9690 2029 7780 6101 -590 9528 9389 1295 7597 5489 9036 4111 6848 6367 5728 7783 8672 4455 7349 5754 9546 1194 391 9337 7748 5828 4912 8500 3010 8983 9877 1235 6371 6950 8942 4055 2111 9469 703 9760 7671 5156 7290 5623 -135 9974 8...
output:
554491818.6160175800
result:
ok found '554491818.6160176', expected '554491808.9394159', error '0.0000000'
Test #22:
score: 0
Accepted
time: 1556ms
memory: 3968kb
input:
-10000 -10000 10000 10000 2000 9179 3249 -7440 6141 1589 9872 -7325 6455 5681 8184 -5197 8181 -4609 8595 8619 4125 6442 6792 -3591 8889 9340 1215 4556 8497 8772 4168 -7033 6910 -6024 7886 9454 1423 2080 9352 799 9732 -1392 9561 -1456 9358 9027 2880 8692 3510 7747 6163 -4921 8380 9405 1846 9325 1029 ...
output:
689400563.3663576841
result:
ok found '689400563.3663577', expected '689400531.7783850', error '0.0000000'
Test #23:
score: 0
Accepted
time: 1702ms
memory: 3972kb
input:
-10000 -10000 10000 10000 2000 -413 9522 8730 4470 3507 9168 5383 8069 8670 4427 -9308 3173 7997 5312 4959 8042 9698 943 7838 5266 -1664 9690 -8665 4435 -7997 5929 -8004 5304 6458 7586 1075 9349 -9665 1477 -9045 3807 -2560 9625 -9175 3732 -2041 9416 4209 8993 -4289 8826 -9394 2481 9442 2659 9358 241...
output:
801988314.3036115170
result:
ok found '801988314.3036115', expected '801988277.6448485', error '0.0000000'
Test #24:
score: 0
Accepted
time: 2219ms
memory: 3948kb
input:
-10000 -10000 10000 10000 2000 -8928 -3936 -6761 7287 -9682 -71 -8639 -3984 -9595 2735 293 9693 2163 9632 -8395 5266 69 9738 -7522 6527 -9270 -2254 1248 9688 -9575 -961 9627 1763 -9052 3587 -7114 6320 1541 9699 9483 1490 9715 929 9537 2145 9232 2774 -8662 4803 -2298 9383 -3408 8923 7113 6554 3071 91...
output:
876785980.4067941904
result:
ok found '876785980.4067942', expected '876785969.0384066', error '0.0000000'
Test #25:
score: 0
Accepted
time: 2167ms
memory: 3976kb
input:
-10000 -10000 10000 10000 2000 -9635 -653 -8720 -4280 -5995 7913 -9350 -2497 -5442 8109 -8247 -5020 -9214 3473 -9607 719 -9089 -3142 -9469 -1962 -9849 -106 9096 3352 -4680 -8597 9250 3140 9456 1742 -3524 8952 6527 7385 -1748 9791 -7220 -6715 9498 2723 4248 8776 -2148 9563 -8946 3525 -8594 -4460 -310...
output:
917958868.5716345310
result:
ok found '917958868.5716345', expected '917958796.4176416', error '0.0000001'
Test #26:
score: 0
Accepted
time: 2397ms
memory: 3956kb
input:
-10000 -10000 10000 10000 2000 -8424 4882 9874 1054 -7516 6283 5824 7919 -9492 2869 -8465 -5065 -7677 6023 9658 1194 -9032 -4038 -1597 9671 -6382 -7575 -7148 6793 -4487 8777 -4574 -8576 5921 7980 -7095 6804 9757 1960 -446 9756 9784 1908 2863 -9539 -860 9863 -9683 1374 -7696 6223 -8488 5254 -9338 262...
output:
949084942.5564858913
result:
ok found '949084942.5564859', expected '949084958.8186604', error '0.0000000'
Test #27:
score: 0
Accepted
time: 2293ms
memory: 4000kb
input:
-10000 -10000 10000 10000 2000 4185 -8886 7933 -5859 -9624 1869 5116 8492 7405 6679 -5390 8255 3698 -9149 -3048 -9443 -4420 8767 4593 8716 -186 9893 -654 9837 6586 7495 4835 8649 -6838 7288 -9548 2300 9526 2926 2929 9402 3564 9256 5371 8359 -9883 306 -9009 -4168 -6262 -7699 -7990 -5794 8096 5562 391...
output:
962273356.3376544714
result:
ok found '962273356.3376545', expected '962273357.4653347', error '0.0000000'
Test #28:
score: 0
Accepted
time: 2705ms
memory: 3916kb
input:
-10000 -10000 10000 10000 2000 -9661 -2487 -3295 -9339 6986 -7122 1152 9901 -7469 6523 -8947 4408 9954 641 -9417 -3097 -4042 9040 3350 9383 1721 -9757 5006 8565 -3414 9369 7563 6502 3795 -9153 7684 6358 2612 -9594 -2043 -9715 9761 -1880 -5955 -8019 -181 9958 8931 4398 -9859 -1329 -5689 8176 -7462 65...
output:
962639211.0699217319
result:
ok found '962639211.0699217', expected '962638552.4635112', error '0.0000007'
Test #29:
score: 0
Accepted
time: 4350ms
memory: 3984kb
input:
-10000 -10000 10000 10000 2000 8501 5255 -8375 5447 -35 -9991 1854 9816 9333 3581 8958 -4423 -6372 -7702 -293 9993 -1478 -9890 -8828 4676 1480 9885 -9766 -2134 -8209 5701 -8515 5226 -9521 -3051 -9975 -587 -6593 7507 2775 9596 -6945 7186 -368 9993 -4697 -8821 -9977 633 -8 9993 -7503 -6601 7996 5999 -...
output:
961606257.3084119558
result:
ok found '961606257.3084120', expected '961606219.6752908', error '0.0000000'
Test #30:
score: -100
Time Limit Exceeded
input:
-10000 -10000 10000 10000 2000 -4177 9085 709 -9974 -9702 2419 -9989 -450 -670 -9977 -8072 5901 -7972 -6036 8638 -5038 -9624 -2714 -9108 4127 6539 -7565 5370 -8435 8466 -5320 -6576 -7533 9035 4285 -5956 -8032 9068 -4215 4025 -9154 5545 8321 7320 -6812 -2950 -9554 8695 4939 9065 4221 3229 9464 -9897 ...