Submission #1607746


Source Code Expand

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

map<pll, ll> mp;

int main(void) {
  int n;
  cin >> n;

  ll s, g;
  cin >> s >> g;

  vector<int> l(n + 1), r(n + 1);
  for (int i = 0; i <= n; i++) {
    cin >> l[i] >> r[i];
  }

  ll pos = s, cnt = 1;
  // double ans = 0.0;
  for (int i = 1; i < n; i++) {
    if (l[i] <= pos && pos <= r[i]) {
      cnt++;
    } else if (pos < l[i]) {
      mp[pll(l[i] - pos, cnt)]++;
      // v.push_back(pll(l[i] - pos, cnt));
      // ans += hypot(l[i] - pos, cnt);
      pos = l[i];
      cnt = 1;
    } else if (pos > r[i]) {   
      mp[pll(r[i] - pos, cnt)]++;
      // v.push_back(pll(pos - r[i], cnt));
      // ans += hypot(pos - r[i], cnt);
      pos = r[i];
      cnt = 1;
    }
  }
  // ans += hypot(g - pos, cnt);
  // v.push_back(pll(g - pos, cnt));
  mp[pll(g - pos, cnt)]++;

  double ans = 0.0;
  for (auto i : mp) {
    ll a = i.first.first * i.second, b = i.first.second * i.second;
    ans += sqrt(a * a + b * b);
  }

  printf("%.15f\n", ans);

  return 0;
}

Submission Info

Submission Time
Task D - レースゲーム
User legosuke
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1118 Byte
Status WA
Exec Time 204 ms
Memory 13568 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 22
WA × 4
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 AC 165 ms 8832 KB
01_rnd_large_01.txt AC 166 ms 8704 KB
01_rnd_large_02.txt AC 166 ms 8832 KB
01_rnd_small_00.txt AC 2 ms 256 KB
01_rnd_small_01.txt AC 2 ms 256 KB
01_rnd_small_02.txt AC 2 ms 256 KB
02_narrowrnd_large_00.txt AC 203 ms 13568 KB
02_narrowrnd_large_01.txt AC 204 ms 13440 KB
02_narrowrnd_small_00.txt AC 2 ms 256 KB
02_narrowrnd_small_01.txt AC 2 ms 256 KB
03_zigzag_large_00.txt WA 99 ms 1792 KB
03_zigzag_small_00.txt AC 2 ms 256 KB
04_middle_large_00.txt AC 193 ms 12288 KB
04_middle_large_01.txt AC 188 ms 10752 KB
04_middle_large_02.txt AC 165 ms 8704 KB
04_middle_small_00.txt AC 2 ms 256 KB
04_middle_small_01.txt AC 2 ms 256 KB
04_middle_small_02.txt AC 2 ms 256 KB
05_turnleft_large_00.txt WA 132 ms 1920 KB
05_turnleft_small_00.txt WA 2 ms 256 KB
06_turnright_large_00.txt WA 130 ms 1920 KB
06_turnright_small_00.txt AC 2 ms 256 KB
07_free_large_00.txt AC 101 ms 1792 KB
07_free_small_00.txt AC 2 ms 256 KB