Submission #5203


Source Code Expand

#include <stdio.h>
#include <iostream>
#include <cmath>
using namespace std;

int N, start, goal;
double x, y;

double nextX(int step){
  int dy = N - y;
  int dx = x - goal;

  if (dy == 0) return -1;

  return (double)(dx * step) / (double)dy;
}


main(){

  cin >> N >> start >> goal;

  double d = 0;

  x = start;
  y = 0;
  //cout << "x: " << x << ", y: " << y << endl;

  for (int i = 0; i <= N; i++){
    int c1, c2;
    cin >> c1 >> c2;

    double next = x + nextX(i - y);
    //cout << "next:" << c1 << " / " << next << " / " << c2 << endl;

    if (c1 <= next && next <= c2){
    }else{
      //int nx = min(abs(x-c1), abs(x-c2));
      int nx = abs(x-c1) < abs(x-c2) ? c1 : c2;
      d += sqrt((double)((nx - x) * (nx - x) + (i - y) * (i - y)));
      x = nx;
      y = i;
      //cout << "#" << i << ",x: " << x << ", y: " << y << ", d: " << d << endl;
    }
  }
  d += sqrt((double)((goal - x) * (goal - x) + (N - y) * (N - y)));
  printf("%.14g\n", d);
}

Submission Info

Submission Time
Task D - レースゲーム
User xrekkusu
Language C++ (GCC 4.4.7)
Score 0
Code Size 1019 Byte
Status WA
Exec Time 235 ms
Memory 700 KB

Judge Result

Set Name all
Score / Max Score 0 / 100
Status
AC × 9
WA × 17
Set Name Test Cases
all 00_sample1.txt, 00_sample2.txt, 01_rnd_large_00.txt, 01_rnd_large_01.txt, 01_rnd_large_02.txt, 01_rnd_small_00.txt, 01_rnd_small_01.txt, 01_rnd_small_02.txt, 02_narrowrnd_large_00.txt, 02_narrowrnd_large_01.txt, 02_narrowrnd_small_00.txt, 02_narrowrnd_small_01.txt, 03_zigzag_large_00.txt, 03_zigzag_small_00.txt, 04_middle_large_00.txt, 04_middle_large_01.txt, 04_middle_large_02.txt, 04_middle_small_00.txt, 04_middle_small_01.txt, 04_middle_small_02.txt, 05_turnleft_large_00.txt, 05_turnleft_small_00.txt, 06_turnright_large_00.txt, 06_turnright_small_00.txt, 07_free_large_00.txt, 07_free_small_00.txt
Case Name Status Exec Time Memory
00_sample1.txt AC 19 ms 128 KB
00_sample2.txt AC 18 ms 128 KB
01_rnd_large_00.txt WA 233 ms 288 KB
01_rnd_large_01.txt WA 231 ms 140 KB
01_rnd_large_02.txt WA 234 ms 260 KB
01_rnd_small_00.txt WA 20 ms 128 KB
01_rnd_small_01.txt WA 20 ms 128 KB
01_rnd_small_02.txt WA 20 ms 128 KB
02_narrowrnd_large_00.txt AC 233 ms 668 KB
02_narrowrnd_large_01.txt AC 232 ms 288 KB
02_narrowrnd_small_00.txt AC 20 ms 128 KB
02_narrowrnd_small_01.txt AC 19 ms 128 KB
03_zigzag_large_00.txt AC 187 ms 688 KB
03_zigzag_small_00.txt AC 19 ms 688 KB
04_middle_large_00.txt WA 233 ms 288 KB
04_middle_large_01.txt WA 234 ms 292 KB
04_middle_large_02.txt WA 233 ms 252 KB
04_middle_small_00.txt WA 20 ms 128 KB
04_middle_small_01.txt WA 20 ms 128 KB
04_middle_small_02.txt WA 20 ms 128 KB
05_turnleft_large_00.txt WA 230 ms 692 KB
05_turnleft_small_00.txt WA 20 ms 128 KB
06_turnright_large_00.txt WA 235 ms 252 KB
06_turnright_small_00.txt WA 20 ms 128 KB
07_free_large_00.txt AC 189 ms 700 KB
07_free_small_00.txt WA 20 ms 128 KB