結果

問題 No.66 輝け☆全国たこやき杯
ユーザー hotpepsi
提出日時 2015-07-26 21:54:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 851 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 64,924 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-16 00:17:47
合計ジャッジ時間 1,076 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
	cout.precision(12);
	int M;
	cin >> M;
	M = 1 << M;
	double S[1024];
	double P[2][1024];
	vector<int> G[2][1024];
	for (int i = 0; i < M; ++i) {
		cin >> S[i];
		S[i] *= S[i];
		P[0][i] = 1.0;
		G[0][i].push_back(i);
	}
	int prev = 0, curr = 1;
	while (M > 1) {
		for (int i = 0; i < M / 2; ++i) {
			G[curr][i].clear();
		}
		for (int i = 0; i < M; ++i) {
			vector<int> &v = G[prev][i];
			vector<int> &opp = G[prev][i ^ 1];
			for (int j : v) {
				double p = 0;
				for (int k : opp) {
					p += P[prev][j] * P[prev][k] * S[j] / (S[j] + S[k]);
				}
				P[curr][j] = p;
				G[curr][j / 2].push_back(j);
			}
		}
		M /= 2;
		prev ^= 1, curr ^= 1;
	}
	double ans = P[prev][0];
	cout << ans << endl;
	return 0;
}
0