Submission #00013


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;
vector<pair<int,int>>s(n);
for(int i=0;i<n;i++){
cin>>s[i].first>>s[i].second;
}
sort(s.begin(),s.end());
double ans=20000000;
int g=15000000;
do{
g--;
double k=sqrt(s[0].first*s[0].first+s[0].second*s[0].second);
for(int i=0;i<n;i++){
if(i==n-1){
k+=sqrt((1000-s[i].first)*(1000-s[i].first)+(1000-s[i].second)*(1000-s[i].second));
}else{
k+=sqrt((s[i].first-s[i+1].first)*(s[i].first-s[i+1].first)+(s[i].second-s[i+1].second)*(s[i].second-s[i+1].second));
}
}
ans=min(ans,k);
if(g==0){
break;
}
}while(next_permutation(s.begin(),s.end()));
printf("%.10lf\n",ans);
}

ステータス

項目 データ
問題 0021 - ひとりたび
ユーザー名 ei2326
投稿日時 2023-11-13 08:39:37
言語 C++17
状態 Wrong Answer
得点 0
ソースコード長 848 Byte
最大実行時間 1000 ms
最大メモリ使用量 732 KB

セット

セット 得点 Cases
1 ALL 0 / 100 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
01.txt AC 20 ms 604 KB
1
02.txt AC 24 ms 572 KB
1
03.txt AC 26 ms 416 KB
1
04.txt AC 20 ms 520 KB
1
05.txt AC 20 ms 624 KB
1
06.txt AC 22 ms 596 KB
1
07.txt AC 19 ms 564 KB
1
08.txt AC 21 ms 536 KB
1
09.txt AC 35 ms 632 KB
1
10.txt AC 191 ms 728 KB
1
11.txt AC 818 ms 696 KB
1
12.txt WA 875 ms 668 KB
1
13.txt AC 955 ms 636 KB
1
sp.txt TLE 1000 ms 732 KB
1