結果

問題 No.813 ユキちゃんの冒険
ユーザー tomatoma
提出日時 2019-04-12 23:21:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,225 bytes
コンパイル時間 1,820 ms
コンパイル使用メモリ 167,448 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-30 13:40:52
合計ジャッジ時間 51,703 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1,804 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1,809 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1,806 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

int N;
ld p, q, dead;
vector<ld> nowv, nextv;

using namespace chrono;
int main()
{
	auto start = system_clock::now();

	cin >> N >> p >> q;
	nowv = vector<ld>(N + 2);
	nextv = vector<ld>(N + 2);
	nowv[1] = 1;

	REP(i, 1e9) {
		fill(nextv.begin(), nextv.end(), 0);
		FOR(j, 1, N) {
			nextv[j - 1] += p * nowv[j];
			nextv[j + 1] += q * nowv[j];
			dead += (1 - p - q)*nowv[j];
		}

		FOR(j, 1, N + 1)nowv[j] = nextv[j];
		nowv[0] += nextv[0];
		nowv[N + 1] += nextv[N + 1];
		if (i % 1000 == 0) {
			auto now = system_clock::now();
			auto dur = duration_cast<milliseconds>(now - start).count();
			//cerr << dur << endl;
			if (dur > 1800) {
				break;
			}
		}
	}
	cout << nowv.front();
	//cout << "back: " << nowv.front() << "  go:" << nowv.back() << "  dead:" << dead << endl;

	return 0;
}
0