結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2019-06-14 23:53:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,089 bytes |
コンパイル時間 | 1,777 ms |
コンパイル使用メモリ | 176,836 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-15 16:49:30 |
合計ジャッジ時間 | 2,672 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {// 1. 入力情報取得.int N;cin >> N;int A[N], B[N];for(int i = 0; i < N; i++) cin >> A[i];for(int i = 0; i < N; i++) cin >> B[i];// 2. sort.sort(A, A + N);sort(B, B + N);// 3. A, B の 順列を保存.vector<vector<int>> va, vb;do{vector<int> v;for(int i = 0; i < N; ++i) v.push_back(A[i]);va.push_back(v);}while(next_permutation(A, A + N));do{vector<int> v;for(int i = 0; i < N; ++i) v.push_back(B[i]);vb.push_back(v);}while(next_permutation(B, B + N));// 4. A君が勝つ確率は?int counter = 0, win = 0;for(auto &a : va){for(auto &b : vb){int aWin = 0;for(int i = 0; i < N; i++) if(a[i] > b[i]) aWin++;if(aWin > N / 2) win++;counter++;}}// 5. 出力.double ans = (win + 0.0) / counter;cout << fixed << setprecision(10) << ans << endl;return 0;}