Submission #2175064


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

int N;
int st;
int gl;
int ls[214514];
int rs[214514];
double ans = 0;

double get_x(int idx, int y, double x) {
  return x + (gl-x)/(N-y)*(idx-y);
}

int main() {
  scanf("%d", &N);
  scanf("%d%d", &st, &gl);
  for (int i=0; i<=N; i++) {
    scanf("%d%d", &ls[i], &rs[i]);
  }

  int y = 0;
  double x = st;
  for (int i=1; i<=N; i++) {
    double c = get_x(i, y, x);
    if (c < ls[i]) {
      ans += sqrt((y-i)*(y-i) + (ls[i]-x)*(ls[i]-x));
      y = i;
      x = ls[i];
    } else if (c > rs[i]) {
      ans += sqrt((y-i)*(y-i) + (rs[i]-x)*(rs[i]-x));
      y = i;
      x = rs[i];
    }
  }
  ans += sqrt((y-N)*(y-N) + (gl-x)*(gl-x));
  printf("%.14f\n", ans);
}

Submission Info

Submission Time
Task D - レースゲーム
User potetisensei
Language C++14 (GCC 5.4.1)
Score 0
Code Size 753 Byte
Status WA
Exec Time 39 ms
Memory 1792 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &N);
                  ^
./Main.cpp:17:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &st, &gl);
                          ^
./Main.cpp:19:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &ls[i], &rs[i]);
                                  ^

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 13
WA × 13
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 1 ms 256 KB
00_sample2.txt AC 1 ms 256 KB
01_rnd_large_00.txt WA 39 ms 1792 KB
01_rnd_large_01.txt AC 39 ms 1792 KB
01_rnd_large_02.txt WA 39 ms 1792 KB
01_rnd_small_00.txt AC 1 ms 256 KB
01_rnd_small_01.txt WA 1 ms 256 KB
01_rnd_small_02.txt WA 1 ms 256 KB
02_narrowrnd_large_00.txt AC 38 ms 1792 KB
02_narrowrnd_large_01.txt AC 38 ms 1792 KB
02_narrowrnd_small_00.txt AC 1 ms 256 KB
02_narrowrnd_small_01.txt AC 1 ms 256 KB
03_zigzag_large_00.txt AC 33 ms 1792 KB
03_zigzag_small_00.txt AC 1 ms 256 KB
04_middle_large_00.txt WA 39 ms 1792 KB
04_middle_large_01.txt WA 39 ms 1792 KB
04_middle_large_02.txt WA 39 ms 1792 KB
04_middle_small_00.txt WA 1 ms 256 KB
04_middle_small_01.txt AC 1 ms 256 KB
04_middle_small_02.txt WA 1 ms 256 KB
05_turnleft_large_00.txt WA 37 ms 1792 KB
05_turnleft_small_00.txt WA 1 ms 256 KB
06_turnright_large_00.txt WA 37 ms 1792 KB
06_turnright_small_00.txt AC 1 ms 256 KB
07_free_large_00.txt WA 33 ms 1792 KB
07_free_small_00.txt AC 1 ms 256 KB