提出 #20791455


ソースコード 拡げる

#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = 3.14159265359;
const ll INF = 1LL << 60;

double dpa[200020];
double dpb[200020];

bool hole[100001];

int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++){
    int a;
    cin >> a;
    hole[a] = true;
  }

  int ct = 0;
  for (int i = 1; i < n; i++){
    if (hole[i]){
      ct++;
      if (ct >= m){
	cout << -1 << endl;
	return 0;
      }
    } else {
      ct = 0;
    }
  }
  
  double suma = 0, sumb = 0;
  for (int i = n-1; i >= 0; i--){
    if (hole[i]){
      dpa[i] = 1.0;
      dpb[i] = 0.0;
    } else {
      dpa[i] = suma / double(m);
      dpb[i] = sumb / double(m) + 1.0;
    }
    suma += dpa[i] - dpa[i+m];
    sumb += dpb[i] - dpb[i+m];
  }

  double ans = dpb[0] / (1 - dpa[0]);
  cout << fixed << setprecision(4) << ans << endl;
  return 0;
}

提出情報

提出日時
問題 F - Sugoroku2
ユーザ unnohideyuki
言語 C++ (GCC 9.2.1)
得点 600
コード長 978 Byte
結果 AC
実行時間 12 ms
メモリ 5348 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 4
AC × 30
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All hand_01.txt, hand_02.txt, hand_04.txt, max_01.txt, max_02.txt, max_03.txt, max_04.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_14.txt, random_15.txt, random_16.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, unreachable_01.txt, unreachable_02.txt, unreachable_03.txt, unreachable_04.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 9 ms 5320 KiB
hand_02.txt AC 2 ms 3504 KiB
hand_04.txt AC 5 ms 3668 KiB
max_01.txt AC 5 ms 5348 KiB
max_02.txt AC 12 ms 5292 KiB
max_03.txt AC 5 ms 5240 KiB
max_04.txt AC 5 ms 5248 KiB
random_01.txt AC 8 ms 5332 KiB
random_02.txt AC 2 ms 3904 KiB
random_03.txt AC 4 ms 5332 KiB
random_04.txt AC 2 ms 3756 KiB
random_05.txt AC 7 ms 5316 KiB
random_06.txt AC 4 ms 5192 KiB
random_07.txt AC 5 ms 5276 KiB
random_08.txt AC 2 ms 3808 KiB
random_09.txt AC 9 ms 5284 KiB
random_10.txt AC 4 ms 4304 KiB
random_11.txt AC 6 ms 5276 KiB
random_12.txt AC 4 ms 5316 KiB
random_14.txt AC 4 ms 4696 KiB
random_15.txt AC 4 ms 5232 KiB
random_16.txt AC 4 ms 4476 KiB
sample_01.txt AC 2 ms 3756 KiB
sample_02.txt AC 2 ms 3692 KiB
sample_03.txt AC 3 ms 3504 KiB
sample_04.txt AC 5 ms 5324 KiB
unreachable_01.txt AC 2 ms 3560 KiB
unreachable_02.txt AC 2 ms 3640 KiB
unreachable_03.txt AC 2 ms 3632 KiB
unreachable_04.txt AC 2 ms 3632 KiB