QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#292371 | #6302. Map | zzuqy | AC ✓ | 1ms | 3908kb | C++14 | 4.7kb | 2023-12-28 02:48:16 | 2023-12-28 02:48:16 |
Judging History
answer
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <utility>
#include <bitset>
#include <set>
#include <map>
#define ll long long
#define db double
#define INF 5000000000000000ll
#define inf 1000000000
#define EPS 1e-12
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define putl(x) printf("%lld\n",x)
#define rep(p,n,i) for(int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define pii pair<int,int>
#define mk make_pair
#define P 1000000007ll
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define sq sqrt
#define l(w) t[w].l
#define r(w) t[w].r
#define m(w) t[w].m
#define mn(w) t[w].mn
#define c(w) t[w].c
#define s(w) t[w].s
#define tag(w) t[w].tag
#define S second
#define F first
#define mod 1000000007
#define sc(A) scanf("%d",&A)
#define scs(A) scanf("%s",A);
#define put(A) printf("%d\n",A)
#define fep(p,n,cc) for(int cc=p;cc>=n;--cc)
#define scl(A) scanf("%lld",&A)
using namespace std;
const int MAXN = 2010;
int T;
int n,k;
pair<db,db> a[MAXN],b[MAXN],d[MAXN];
pair<db,db> A[MAXN],B[MAXN];
pair<db,db> w1[MAXN],w2[MAXN];
int s1,s2,s3,s4;
void gb(db &w){if(fabs(w)<=EPS)w=0;}
int main()
{
//freopen("1.in","r",stdin);
sc(T);
while(T--)
{
db ans=2000000000;
sc(s1);sc(s2);
a[1].F=s1;a[1].S=s2;
sc(s1);sc(s2);
b[1].F=s1;b[1].S=s2;
sc(s1);sc(s2);
//c[1].F=s1;c[1].S=s2;
sc(s1);sc(s2);
d[1].F=s1;d[1].S=s2;
A[1]=mk(b[1].F-a[1].F,b[1].S-a[1].S);
B[1]=mk(d[1].F-a[1].F,d[1].S-a[1].S);
sc(s1);sc(s2);
a[2].F=s1;a[2].S=s2;
sc(s1);sc(s2);
b[2].F=s1;b[2].S=s2;
sc(s1);sc(s2);
//c[1].F=s1;c[1].S=s2;
sc(s1);sc(s2);
d[2].F=s1;d[2].S=s2;
A[2]=mk(b[2].F-a[2].F,b[2].S-a[2].S);
B[2]=mk(d[2].F-a[2].F,d[2].S-a[2].S);
sc(s1);
sc(s2);
sc(s3);
sc(s4);
w1[1].F=s1;w1[1].S=s2;
w2[1].F=s3;w2[1].S=s4;
sc(k);sc(n);
rep(3,n+1,i)
{
//求a的(x,y)坐标
//(x,y)=(x',y')A^{-1}
db det=A[i-2].F*B[i-2].S-A[i-2].S*B[i-2].F;
det=1/det;
db xx=a[i-1].F-a[i-2].F;
db yy=a[i-1].S-a[i-2].S;
db x=B[i-2].S*xx-B[i-2].F*yy;
db y=-A[i-2].S*xx+A[i-2].F*yy;
x=x*det;
y=y*det;
//cout<<x<<' '<<y<<endl;
xx=x*A[i-1].F+y*B[i-1].F;
yy=x*A[i-1].S+y*B[i-1].S;
//cout<<xx<<' '<<yy<<endl;
gb(xx);gb(yy);
a[i].F=xx+a[i-1].F;
a[i].S=yy+a[i-1].S;
gb(a[i].S);gb(a[i].F);
xx=b[i-1].F-a[i-2].F;
yy=b[i-1].S-a[i-2].S;
x=B[i-2].S*xx-B[i-2].F*yy;
y=-A[i-2].S*xx+A[i-2].F*yy;
x=x*det;
y=y*det;
//cout<<x<<' '<<y<<endl;
xx=x*A[i-1].F+y*B[i-1].F;
yy=x*A[i-1].S+y*B[i-1].S;
//cout<<xx<<' '<<yy<<endl;
gb(xx);gb(yy);
b[i].F=xx+a[i-1].F;
b[i].S=yy+a[i-1].S;
xx=d[i-1].F-a[i-2].F;
yy=d[i-1].S-a[i-2].S;
x=B[i-2].S*xx-B[i-2].F*yy;
y=-A[i-2].S*xx+A[i-2].F*yy;
x=x*det;
y=y*det;
//cout<<x<<' '<<y<<endl;
xx=x*A[i-1].F+y*B[i-1].F;
yy=x*A[i-1].S+y*B[i-1].S;
//cout<<xx<<' '<<yy<<endl;
gb(xx);gb(yy);
d[i].F=xx+a[i-1].F;
d[i].S=yy+a[i-1].S;
//cout<<d[i].F<<' '<<d[i].S<<endl;
A[i]=mk(b[i].F-a[i].F,b[i].S-a[i].S);
B[i]=mk(d[i].F-a[i].F,d[i].S-a[i].S);
}
db det=A[1].F*B[1].S-A[1].S*B[1].F;
det=1/det;
db xx=w1[1].F-a[1].F;
db yy=w1[1].S-a[1].S;
db x=B[1].S*xx-B[1].F*yy;
db y=-A[1].S*xx+A[1].F*yy;
x=x*det;
y=y*det;
gb(x);gb(y);
rep(2,n+1,i)
{
w1[i].F=x*A[i].F+y*B[i].F+a[i].F;
w1[i].S=x*A[i].S+y*B[i].S+a[i].S;
gb(w1[i].F);gb(w1[i].F);
//cout<<w1[i].F<<' '<<w1[i].S<<endl;
}
det=A[1].F*B[1].S-A[1].S*B[1].F;
det=1/det;
xx=w2[1].F-a[1].F;
yy=w2[1].S-a[1].S;
x=B[1].S*xx-B[1].F*yy;
y=-A[1].S*xx+A[1].F*yy;
x=x*det;
y=y*det;
gb(x);gb(y);
rep(2,n+1,i)
{
w2[i].F=x*A[i].F+y*B[i].F+a[i].F;
w2[i].S=x*A[i].S+y*B[i].S+a[i].S;
gb(w2[i].F);gb(w2[i].F);
//cout<<w2[i].F<<' '<<w2[i].S<<endl;
}
rep(0,n,i)rep(0,n-i,j)
{
if(k*(i+j)>=ans)continue;
x=w1[i+1].F-w2[j+1].F;
y=w1[i+1].S-w2[j+1].S;
x=x*x+y*y;
x=sqrt(x);
gb(x);
//cout<<i<<' '<<j<<' '<<x<<' '<<w1[i+1].F<<' '<<w2[j+1].F<<' '<<w1[i+1].S<<' '<<w2[j+1].S<<endl;
ans=min(ans,k*(i+j)+x);
}
printf("%.10lf\n",ans);
//printf("%.10lf\n",fabs(ans)<=EPS?0:ans);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3848kb
input:
2 0 0 0 2 4 2 4 0 0 0 0 1 2 1 2 0 2 1 4 2 1 1 0 0 0 3 6 3 6 0 0 1 1 0 3 2 2 3 0 0 4 2 0 3
output:
1.0000000000 1.2272623352
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 1ms
memory: 3784kb
input:
100 -133 -128 -109 -134 -85 -38 -109 -32 -95 -37 -100 -35 -108 -55 -103 -57 -119 -130 -112 -44 2 73 5 -100 5 -8 1 -8 1 -100 1 -60 1 -14 3 -14 3 -60 3 -84 1 -20 2 53 -58 -78 -66 -78 -66 -34 -58 -34 -58 -34 -66 -34 -66 -78 -58 -78 -63 -50 -63 -37 4 54 52 -148 116 -148 116 -52 52 -52 53 -103 53 -71 101...
output:
9.5006574997 12.2297310789 13.0000000000 17.4885329004 13.3416640641 7.6157731059 23.4093998214 7.2801098893 21.2800377341 59.7760220926 4.1231056256 79.6492310070 65.0691939400 14.1421356237 41.8246155035 16.0562451849 15.6726175299 21.5622023742 66.2721661031 21.0237960416 20.8806130178 24.3310501...
result:
ok 100 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
100 -173 -113 -120 -113 -120 -115 -173 -115 -173 -115 -120 -115 -120 -113 -173 -113 -162 -114 -152 -114 99 57 6 23 -75 4 -56 -77 25 -58 0 -58 -51 -69 -62 -18 -11 -7 -22 -56 -42 -25 19 27 -98 -115 -150 -147 -158 -134 -106 -102 -150 -147 -98 -115 -106 -102 -158 -134 -103 -111 -136 -134 25 50 136 -92 1...
output:
10.0000000000 25.4836379756 40.2243707222 18.3847763109 9.2195444573 18.0277563773 43.1140630263 52.8870443523 45.5411901469 55.0009999750 37.0000000000 12.0415945788 24.3310501212 18.1107702763 7.5632627533 2.2360679775 8.2360679775 14.8647651089 6.3245553203 62.4873265669 37.6563407675 4.472135955...
result:
ok 100 numbers
Test #4:
score: 0
Accepted
time: 1ms
memory: 3900kb
input:
100 -12 -206 72 -188 135 -482 51 -500 19 -301 23 -301 23 -315 19 -315 88 -368 28 -248 14 87 -221 -566 -467 -566 -467 -565 -221 -565 -221 -566 -467 -566 -467 -565 -221 -565 -297 -566 -289 -566 274 18 -264 759 -339 609 -129 504 -54 654 -208 580 -208 655 -103 655 -103 580 -196 664 -211 596 8 64 -111 -3...
output:
34.2469504755 8.0000000000 45.9269522868 135.1184665396 131.9734821849 40.3496659540 15.3213477287 77.7722750350 66.7388130359 8.0002666548 116.8064460317 12.5882900156 170.7856302663 131.9627504291 8.7380899752 17.4642491966 15.4996598429 26.0698361456 258.0736329035 17.7457353296 25.7500000000 98....
result:
ok 100 numbers
Test #5:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
100 -235 -704 133 -704 133 -720 -235 -720 -224 -712 -40 -712 -40 -704 -224 -704 15 -711 76 -718 4 74 -467 574 -475 596 -123 724 -115 702 -274 662 -270 652 -430 588 -434 598 -458 588 -241 657 15 31 380 -3 532 -343 787 -229 635 111 503 -71 639 -163 708 -61 572 31 533 -189 613 -137 3 58 -460 -7 -488 -7...
output:
31.3500814330 51.9676323209 21.4686979281 38.8379320765 84.2481874283 77.9294552785 47.0000000000 74.1154937259 86.4671048804 35.1140997322 3.6055512755 97.4166310237 24.6060569658 56.7733594327 6.9985346194 13.4536240471 150.7861657235 65.8559033041 26.1725046566 128.0351514233 276.0018115883 86.99...
result:
ok 100 numbers
Test #6:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
100 -1201 2822 -1197 2814 -3437 1694 -3441 1702 -3119 1860 -3117 1856 -1997 2416 -1999 2420 -1419 2709 -2491 2174 48 76 -2515 285 -2547 306 -1308 2194 -1276 2173 -2255 683 -2260 686 -2083 981 -2078 978 -1572 1753 -1392 2015 121 28 -1216 1209 -1498 -1141 -1598 -1129 -1316 1221 -1494 -823 -1494 -447 -...
output:
264.0558635329 290.4257004509 258.2824003131 743.7371847635 341.0527818388 400.5666836624 172.0407993410 27.7708946098 294.8258801521 508.0659106889 501.7818250993 666.8050689669 180.0694310537 193.6104336032 1507.0029860621 25.0199920064 81.7480074985 346.0289842897 105.4786686998 233.0047954418 10...
result:
ok 100 numbers
Test #7:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
100 1411 -2755 603 -3563 623 -3583 1431 -2775 716 -3477 1120 -3073 1110 -3063 706 -3467 1210 -2959 1339 -2830 2319 39 4528 -3417 4286 -4055 1908 -3153 2150 -2515 2094 -2892 2094 -3090 2832 -3090 2832 -2892 2257 -2993 4389 -3736 17 22 -180 -1673 -2172 -3665 -2164 -3673 -172 -1681 -284 -1792 -2027 -35...
output:
182.4335495461 96.8809230539 530.3300858899 44.0113621693 64.3133653662 7.3928936661 34.5678102075 148.8501607430 350.3381359161 329.2251627798 68.8647651089 32.8243831746 244.6957294274 685.9688377120 141.3627479959 1601.7898267227 6.8855911462 70.6714607056 5.1796544293 277.0649743291 49.481667656...
result:
ok 100 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
100 11928 -18111 8928 -17411 11056 -8291 14056 -8991 11043 -10811 10793 -10111 12921 -9351 13171 -10051 10491 -14092 11923 -12413 10 92 11869 -4371 3539 5429 1299 3525 9629 -6275 8302 -3064 3647 2571 4935 3635 9590 -2000 2384 2680 3466 2644 181 91 4001 -10187 4001 -10897 9 -10897 9 -10187 838 -10629...
output:
87.4796570026 977.2093228206 94.4863250594 307.0065145889 1245.6295597006 532.0000000000 369.0487772639 19.5540243172 1509.0000000000 275.0942672113 4242.1933515147 465.6562514088 3478.3042420602 1754.3560072004 1804.4669275859 21.3531426606 415.4155346246 1526.4344073690 3853.6029365080 3165.826590...
result:
ok 100 numbers
Test #9:
score: 0
Accepted
time: 1ms
memory: 3908kb
input:
100 10303 -4099 19487 -8131 19703 -7639 10519 -3607 18394 -7495 18842 -7271 18854 -7295 18406 -7519 15852 -6248 15950 -6389 38 10 13132 -3411 17416 3393 15634 4515 11350 -2289 13143 -873 15411 3411 16533 2817 14265 -1467 16515 2577 16017 1561 198 94 -5480 10872 -6297 11294 -11361 1490 -10544 1068 -1...
output:
84.5748864893 999.6892776781 6231.5296677461 550.9478860950 182.5441246586 5374.2967912091 825.7257810967 1653.2074291692 2777.1096485375 166.6530238061 1747.0045792728 651.1113576033 242.2100067323 34.2668958462 286.7908645686 2405.2466289206 2133.3422135232 1310.9781315738 48.4664832642 464.432837...
result:
ok 100 numbers
Test #10:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
100 0 -30 84 12 126 -72 42 -114 0 -30 84 12 126 -72 42 -114 91 -41 100 -55 96 93 168 110 148 150 48 100 68 60 48 100 68 60 168 110 148 150 61 96 102 90 8 2 -123 129 -60 174 -15 111 -78 66 -15 111 -78 66 -123 129 -60 174 -44 115 -104 132 27 3 27 42 15 54 -75 -36 -63 -48 -63 -48 -75 -36 15 54 27 42 -4...
output:
16.6433169771 41.4366987102 39.2065556157 11.1803398875 49.7292670366 26.9258240357 50.9313263130 10.2940558202 117.8855377050 8.6023252670 48.4664832642 21.0950231097 24.0384048104 16.0000000000 48.5489443758 26.0617568596 39.5398320783 10.7703296143 20.9732137495 7.2801098893 56.2938717802 66.6448...
result:
ok 100 numbers
Test #11:
score: 0
Accepted
time: 1ms
memory: 3752kb
input:
100 9725 6731 9725 11971 14965 11971 14965 6731 9725 6731 9725 11971 14965 11971 14965 6731 10293 11185 10445 9833 488 10 3833 -4831 6913 -4271 8443 -12686 5363 -13246 6913 -4271 3833 -4831 5363 -13246 8443 -12686 5209 -4960 7133 -6409 1 88 -5891 -6066 -8365 -6066 -8365 -8540 -5891 -8540 -8365 -6066...
output:
1360.5175485822 2119.6747801397 1638.6014941954 144.6996890114 1706.2992117445 2671.6680182987 1442.3248593850 2909.9312706660 5311.3863538628 7894.8442036560 2950.7214372082 1405.1972795872 8052.7859775360 436.0848541282 1910.1901471238 1597.0078271568 8923.0793451588 3776.2335732844 6300.141744437...
result:
ok 100 numbers
Test #12:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
100 1432065 -1359744 1432065 -1359796 610089 -1359796 610089 -1359744 610089 -1359744 610089 -1359796 1432065 -1359796 1432065 -1359744 1413145 -1359747 670086 -1359765 306 12 -630899 -570942 344981 -570942 344981 -567164 -630899 -567164 -630899 -567164 344981 -567164 344981 -570942 -630899 -570942 ...
output:
41383.0039438126 344430.7087644771 597464.9471601223 57512.0000212513 180112.5049839492 254594.1894654636 13301.8343676309 246235.7413415039 17086.9537366963 168329.0011881494 580568.2784376012 120047.4759650452 24722.5759377942 252882.7987190904 366.8823411459 108187.7685733368 2882.0751160504 3104...
result:
ok 100 numbers
Test #13:
score: 0
Accepted
time: 1ms
memory: 3792kb
input:
100 -240497 1168822 -365542 931192 504344 473443 629389 711073 226221 683190 167481 688085 185400 903113 244140 898218 -192129 1110656 34450 941656 2 25 1729381 25950 1512625 519672 1528369 526584 1745125 32862 1536820 492965 1580974 388601 1584302 390009 1540148 494373 1660204 207517 1601591 344571...
output:
33.5237736391 126504.9995186089 57518.2936973329 318943.6637025417 169769.2500056688 1497.1338930673 23459.3249919649 853.3478160954 28.3514118459 7526.1065240365 36705.8165690398 575.0153216759 4025.0848822247 31458.0236664670 316549.0145569877 52928.3708893444 136396.3932914862 10642.3616271967 11...
result:
ok 100 numbers
Test #14:
score: 0
Accepted
time: 1ms
memory: 3792kb
input:
100 -889209 606569 -191736 1436894 638589 739421 -58884 -90904 -58884 -90904 638589 739421 -191736 1436894 -889209 606569 -486300 891465 -464854 988546 79 18 -1226546 957048 -712144 1926170 -590407 1861553 -1104809 892431 -712144 1926170 -1226546 957048 -1104809 892431 -590407 1861553 -807239 146415...
output:
99421.5845629107 404181.3888243742 311311.5289175780 271785.6245370604 319158.1918390941 77725.0255434951 103690.2415692899 33781.0042775522 16708.6083501888 262422.7682271491 176381.8430933297 159818.4839403753 451836.6342208136 291664.0401808879 406095.2666124046 591425.3179869796 728801.794638981...
result:
ok 100 numbers