답안 #9046

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
9046 2014-09-27T10:59:37 Z dolpang2 Wall construction (kriii2_WA) C++14
1 / 4
0 ms 1220 KB
#include <cstdio>
#include <cmath>
#include <vector>

struct Point {
  int x;
  int y;
};

int main() {
  std::vector<Point> bundle;
  int N;
  int R;

  scanf(" %d %d", &N, &R);
  for (int i = 0; i < N; ++i) {
    int x;
    int y;

    scanf(" %d %d", &x, &y);
    Point p;
    p.x = x;
    p.y = y;
    bundle.push_back(p);
  }
  if (N == 2) {
    double dis = sqrt((bundle[0].x - bundle[1].x) * (bundle[0].x - bundle[1].x) +
      (bundle[0].y - bundle[1].y) * (bundle[0].y - bundle[1].y));
    printf("%lf", 2 * dis + 2 * 3.14159265359 * R);
  }
  else {
    // 1사분면
    Point one = bundle[0];
    Point two = bundle[0];
    Point three = bundle[0];
    Point four = bundle[0];
    for (int i = 0; i < N; ++i) {
      if (bundle[i].x > one.x || bundle[i].y > one.y) {
        one = bundle[i];
      }if (bundle[i].x < two.x || bundle[i].y > two.y) {
        two = bundle[i];
      }
      if (bundle[i].x < three.x || bundle[i].y < three.y) {
        three = bundle[i];
      }
      if (bundle[i].x > four.x || bundle[i].y < four.y) {
        four = bundle[i];
      }
    }



    long double dis = sqrt((one.x - two.x) * (one.x - two.x) +
      (one.y - two.y) * (one.y - two.y));
    dis += sqrt((three.x - two.x) * (three.x - two.x) +
      (three.y - two.y) * (three.y - two.y));
    dis += sqrt((three.x - four.x) * (three.x - four.x) +
      (three.y - four.y) * (three.y - four.y));
    dis += sqrt((one.x - four.x) * (one.x - four.x) +
      (one.y - four.y) * (one.y - four.y));
    printf("%.12Lf", dis + 2 * 3.14159265359 * R);

  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1220 KB Output is correct
2 Correct 0 ms 1220 KB Output is correct
3 Correct 0 ms 1220 KB Output is correct
4 Correct 0 ms 1220 KB Output is correct
5 Correct 0 ms 1220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1220 KB Output is correct
2 Incorrect 0 ms 1220 KB Output isn't correct
3 Halted 0 ms 0 KB -