結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2020-08-08 10:15:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,284 bytes |
コンパイル時間 | 1,837 ms |
コンパイル使用メモリ | 173,436 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-01 07:44:13 |
合計ジャッジ時間 | 2,301 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;const double pi=3.141592653589793;typedef unsigned long long ull;typedef long double ldouble;const ll INF=1e18;#define rep(i, n) for(int i = 0; i < (int)(n); i++)#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)const int MAX_N = 362881;// 重複があってもすべての順列を列挙する// next_permutationは辞書順で次の順列を生成するint perm[MAX_N];int perm2[MAX_N];int num = 0;int all = 0;void permutation2(int n) {do {// permに対する操作int win=0;rep(i, n){if(perm[i] > perm2[i]) win++;}if(win > (n/2)) num++;all++;} while (next_permutation(perm2, perm2 + n));return;}void permutation(int n) {do {// permに対する操作permutation2(n);} while (next_permutation(perm, perm + n));return;}int main(){int n;cin >> n;vector<int> a(n), b(n);rep(i, n) cin >> a.at(i);rep(i, n) cin >> b.at(i);sort(a.begin(), a.end());sort(b.begin(), b.end());rep(i, n) perm[i] = a.at(i);rep(i, n) perm2[i] = b.at(i);permutation(n);ldouble p = (ldouble) num / (ldouble) all;cout << p << endl;}