Submission #8471859


Source Code Expand

Copy
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int N = 9;

int x[N];
int y[N];
int p[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", x + i, y + i);
    p[i] = i;
  }
  double ans = 0;
  do {
    for (int i = 0; i < n - 1; ++i) {
      ans += sqrt((x[p[i]] - x[p[i + 1]]) * (x[p[i]] - x[p[i + 1]]) + (y[p[i]] - y[p[i + 1]]) * (y[p[i]] - y[p[i + 1]]));
    }
  } while (next_permutation(p, p + n));
  for (int i = 2; i <= n; ++i) {
    ans /= i;
  }
  printf("%.15f\n", ans);
}

Submission Info

Submission Time
Task C - Average Length
User fragusbot
Language C++14 (GCC 5.4.1)
Score 300
Code Size 592 Byte
Status AC
Exec Time 2 ms
Memory 128 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
                  ^
./Main.cpp:17:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", x + i, y + i);
                                ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample sample00, sample01, sample02
All handmade03, handmade04, handmade05, random06, random07, random08, random09, random10, random11, random12, random13, random14, sample00, sample01, sample02
Case Name Status Exec Time Memory
handmade03 AC 2 ms 128 KB
handmade04 AC 2 ms 128 KB
handmade05 AC 2 ms 128 KB
random06 AC 1 ms 128 KB
random07 AC 1 ms 128 KB
random08 AC 1 ms 128 KB
random09 AC 1 ms 128 KB
random10 AC 1 ms 128 KB
random11 AC 1 ms 128 KB
random12 AC 2 ms 128 KB
random13 AC 2 ms 128 KB
random14 AC 2 ms 128 KB
sample00 AC 1 ms 128 KB
sample01 AC 1 ms 128 KB
sample02 AC 2 ms 128 KB