Submission #34076970


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

using ll = long long;
typedef pair<double,double> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(ll i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
void coT() {cout <<"Takahashi"<<endl;}
void coA(){cout <<"Aoki"<<endl;}

void mswap(ll &a, ll &b){ if(a >= b) swap(a,b); }
void rswap(ll &a, ll &b){ if(a <= b) swap(a,b); }

const ll dy[] = {0,0,1,-1};
const ll dx[] = {1,-1,0,0};
const ll mod = 1e9+7;
const ll MOD = 998244353;
using mint = modint998244353;
const double PI=3.14159265358979323846;
const ll inf = 1001001001;
const ll INF = 1'000'000'000'000'000'000;
vector<ll> to[200'005];
//Write From this Line
P dp[200'005];
int main()
{
	int n, m, k;
	cin >> n>> m>> k;
	map<int,bool> mp;
	rep(i,k){
		int x;
		cin >> x;
		mp[x] = true;
	}
	int ren = 0;
	rep(i,n){
		if(mp[i]){
			ren ++;
			if(ren >= m){
				cout << -1 << endl;
				return 0;
			}
		} else {
			ren = 0;
		}
	}
	dp[n] = P(0,0);
	for(int i=n; i<=n+m; i++){
		dp[i] = P(0,0);
	}
	P syaku = P(0,0);
	for(int i = n-1; i >= 0; i--){
		if(mp[i]){
			dp[i] = P(1,0);
		} else {
			dp[i].first = syaku.first/m;
			dp[i].second = 1+(syaku.second/m);
		}
		syaku.first -= dp[i+m].first;
		syaku.second -= dp[i+m].second;
		syaku.first += dp[i].first;
		syaku.second += dp[i].second;
	}
	double ans = dp[0].second / (1-dp[0].first);
	cout << setprecision(15);
	cout << ans << endl;
}

Submission Info

Submission Time
Task F - Sugoroku2
User nibosea
Language C++ (GCC 9.2.1)
Score 600
Code Size 1925 Byte
Status AC
Exec Time 42 ms
Memory 16268 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 4
AC × 30
Set Name Test Cases
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
Case Name Status Exec Time Memory
hand_01.txt AC 40 ms 14800 KiB
hand_02.txt AC 6 ms 8156 KiB
hand_04.txt AC 5 ms 8472 KiB
max_01.txt AC 39 ms 14648 KiB
max_02.txt AC 39 ms 14720 KiB
max_03.txt AC 37 ms 14664 KiB
max_04.txt AC 38 ms 14668 KiB
random_01.txt AC 41 ms 16228 KiB
random_02.txt AC 12 ms 10872 KiB
random_03.txt AC 40 ms 14644 KiB
random_04.txt AC 8 ms 8628 KiB
random_05.txt AC 42 ms 16268 KiB
random_06.txt AC 39 ms 15868 KiB
random_07.txt AC 38 ms 14612 KiB
random_08.txt AC 8 ms 8624 KiB
random_09.txt AC 37 ms 16216 KiB
random_10.txt AC 17 ms 12296 KiB
random_11.txt AC 35 ms 14664 KiB
random_12.txt AC 34 ms 14748 KiB
random_14.txt AC 22 ms 13788 KiB
random_15.txt AC 38 ms 14616 KiB
random_16.txt AC 18 ms 11192 KiB
sample_01.txt AC 8 ms 8420 KiB
sample_02.txt AC 6 ms 8396 KiB
sample_03.txt AC 3 ms 8332 KiB
sample_04.txt AC 35 ms 14720 KiB
unreachable_01.txt AC 7 ms 8336 KiB
unreachable_02.txt AC 18 ms 10596 KiB
unreachable_03.txt AC 13 ms 9524 KiB
unreachable_04.txt AC 15 ms 10104 KiB