提出 #35879803
ソースコード 拡げる
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
typedef long long ll;
using namespace std;
const long double inf = 1e18;
int n, m;
long double f[1 << 13][1 << 5][18], v[20];
// 0 ~ n - 1
// n ~ n + m - 1
struct node {
long double x, y;
} a[20], b[20];
long double getdis(int x, int y) {
long double x1, x2, y1, y2;
if(x < n) {
x1 = a[x].x;
y1 = a[x].y;
}
else {
x1 = b[x - n].x;
y1 = b[x - n].y;
}
if(y < n) {
x2 = a[y].x;
y2 = a[y].y;
}
else {
x2 = b[y - n].x;
y2 = b[y - n].y;
}
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
int main() {
#ifdef DEBUG
freopen("1.in", "r", stdin);
#endif
cin >> n >> m;
for(int i = 1; i <= n; i++) {
cin >> a[i].x >> a[i].y;
}
n++;
for(int i = 0; i < m; i++) {
cin >> b[i].x >> b[i].y;
}
for(int s = 0; s < (1 << n); s++) {
for(int t = 0; t < (1 << m); t++) {
for(int i = 0; i < n + m; i++) {
f[s][t][i] = inf;
}
}
}
v[0] = 1;
for(int i = 1; i <= m; i++) {
v[i] = v[i - 1] * 2;
}
f[1][0][0] = 0;
for(int s1 = 0; s1 < (1 << n); s1++) {
for(int s2 = 0; s2 < (1 << m); s2++) {
for(int i = 0; i < n + m; i++) {
if(f[s1][s2][i] == inf) {
continue;
}
long double t = v[__builtin_popcount(s2)];
for(int j = 0; j < n; j++) {
if(s1 >> j & 1) {
continue;
}
f[s1 | (1 << j)][s2][j] = min(f[s1 | (1 << j)][s2][j], f[s1][s2][i] + getdis(i, j) / t);
}
for(int j = 0; j < m; j++) {
if(s2 >> j & 1) {
continue;
}
f[s1][s2 | (1 << j)][j + n] = min(f[s1][s2 | (1 << j)][j + n], f[s1][s2][i] + getdis(i, j + n) / t);
}
}
}
}
long double ans = inf;
for(int s = 0; s < (1 << m); s++) {
long double t = v[__builtin_popcount(s)];
for(int i = 0; i < n + m; i++) {
ans = min(ans, f[(1 << n) - 1][s][i] + getdis(i, 0) / t);
}
}
printf("%.10Lf\n", ans);
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | E - Booster |
| ユーザ | yanchengzhi |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 500 |
| コード長 | 2020 Byte |
| 結果 | AC |
| 実行時間 | 224 ms |
| メモリ | 77528 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 500 / 500 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, sample_01.txt, sample_02.txt, sample_03.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| random_01.txt | AC | 223 ms | 77308 KiB |
| random_02.txt | AC | 10 ms | 5940 KiB |
| random_03.txt | AC | 220 ms | 77484 KiB |
| random_04.txt | AC | 2 ms | 3872 KiB |
| random_05.txt | AC | 222 ms | 77380 KiB |
| random_06.txt | AC | 6 ms | 4736 KiB |
| random_07.txt | AC | 35 ms | 44588 KiB |
| random_08.txt | AC | 110 ms | 40596 KiB |
| random_09.txt | AC | 218 ms | 77452 KiB |
| random_10.txt | AC | 32 ms | 12872 KiB |
| random_11.txt | AC | 40 ms | 44684 KiB |
| random_12.txt | AC | 7 ms | 7380 KiB |
| random_13.txt | AC | 224 ms | 77388 KiB |
| random_14.txt | AC | 220 ms | 77528 KiB |
| random_15.txt | AC | 78 ms | 61144 KiB |
| random_16.txt | AC | 15 ms | 8776 KiB |
| random_17.txt | AC | 221 ms | 77288 KiB |
| random_18.txt | AC | 2 ms | 3808 KiB |
| random_19.txt | AC | 38 ms | 44524 KiB |
| random_20.txt | AC | 3 ms | 3628 KiB |
| sample_01.txt | AC | 2 ms | 3764 KiB |
| sample_02.txt | AC | 2 ms | 3624 KiB |
| sample_03.txt | AC | 1 ms | 3580 KiB |