結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-03-17 14:11:13 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 5,000 ms | 
| コード長 | 1,497 bytes | 
| コンパイル時間 | 834 ms | 
| コンパイル使用メモリ | 95,604 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-30 21:53:33 | 
| 合計ジャッジ時間 | 1,846 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
using namespace std;
typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;
const double PI=3.14159265358979323846;
#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))
#define rep(i, N) for(int i = 0; i < N; ++i)
#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL
#define IN(l, r, x) ((l) <= (x) && (x) < (r))
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vs32 a(n);
    vs32 b(n);
    rep (i, n) cin >> a[i];
    rep (i, n) cin >> b[i];
    vs32 va(n);
    vs32 vb(n);
    rep (i, n) va[i] = vb[i] = i;
    int numg = 0;
    int numw = 0;
    do {
        do {
            int sa = 0;
            int sb = 0;
            rep (i, n)
            {
                if (a[va[i]] > b[vb[i]]) ++sa;
                else ++sb;
            }
            if (sa > sb) ++numw;
            ++numg;
        } while (next_permutation(vb.begin(), vb.end()));
    } while (next_permutation(va.begin(), va.end()));
    cout << setprecision(10) << (double)numw / (double)numg << "\n";
    return 0;
}
            
            
            
        