QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#536611 | #5809. Min Perimeter | zhicheng | 5 | 15774ms | 11860kb | C++14 | 1.3kb | 2024-08-29 14:58:18 | 2024-08-29 14:58:19 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
namespace IO{
inline char gc(){
static const int Rlen=1<<18|1;static char buf[Rlen],*p1,*p2;
return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,Rlen,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>T get_integer(){
char c;bool f=false;while(!isdigit(c=gc()))f=c=='-';T x=c^48;
while(isdigit(c=gc()))x=((x+(x<<2))<<1)+(c^48);return f?-x:x;
}
inline int gi(){return get_integer<int>();}
}
using namespace std;
using namespace IO;
const int N=1000010;
int n;
struct s{
int x,y;
bool operator<(s b){
return x<b.x;
}
bool operator==(s b){
return x==b.x&&y==b.y;
}
}p[N];
double dist(s a,s b){
return sqrt(1ll*(a.x-b.x)*(a.x-b.x)+1ll*(a.y-b.y)*(a.y-b.y));
}
double dis(int i,int j){
return dist(p[i],p[j]);
}
void solve(){
double ans=1e18,sum;
sort(p+1,p+n+1);
for(int i=1;i<=n;i++){
for(int j=i+2;j<=min(n,i+400);j++){
if(dis(i,j)>=ans/2){
continue;
}
if(p[j].x-p[i].x>=ans/2){
break;
}
sum=1e18;
for(int k=i+1;k<=j-1;k++){
sum=min(sum,dis(i,k)+dis(k,j));
}
ans=min(ans,sum+dis(i,j));
}
}
printf("%.6lf\n",ans);
}
int main(){
int t=gi();
for(int tt=1;tt<=t;tt++){
n=gi();
for(int i=1;i<=n;i++){
p[i].x=gi();
p[i].y=gi();
}
printf("Case #%d: ",tt);
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 104ms
memory: 4192kb
input:
15 3 2 6 7 0 3 0 3 713 269 371 79 455 421 3 91983245 637281504 756917015 312173515 869576338 436726680 10000 14761642 78236002 9047458 47951098 5238002 27761162 476182 2523742 1428546 7571226 26190010 138805810 21904372 116092132 18094916 95902196 43332562 229660522 55237112 292754072 52380020 27761...
output:
Case #1: 17.893012 Case #2: 1042.844835 Case #3: 1711142102.791327 Case #4: 90912.296374 Case #5: 3.414214 Case #6: 26.153830 Case #7: 1701.012681 Case #8: 2865438.191994 Case #9: 2020088.337226 Case #10: 1792106.037292 Case #11: 2019352.542910 Case #12: 2530195.728018 Case #13: 930517.779631 Case #...
result:
ok correct! (15 test cases)
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 15774ms
memory: 11860kb
input:
15 3 501691275 344354353 167768963 536043860 249445040 557426549 4 1000000000 0 0 0 1000000000 1000000000 0 1000000000 1000000 138925776 669369648 61257680 295150640 170762328 822763944 55483472 267329456 97736936 470914328 84041848 404928904 18463588 88960924 124429360 599523280 95066048 458045504 ...
output:
Case #1: 799653579.133090 Case #2: 3414213562.373095 Case #3: 866.071591 Case #4: 62459.895370 Case #5: 59141.918359 Case #6: 898200.352465 Case #7: 1707101.209072 Case #8: 1686.226798 Case #9: 1702.080488 Case #10: 6806.665584 Case #11: 1907380.086815 Case #12: 1798845.754533 Case #13: 2000012.1876...
result:
wrong answer read 1702.080488000000 but expected 1686.603545971635 (test case 9)