結果

問題 No.133 カードゲーム
ユーザー minatominato
提出日時 2019-12-16 10:44:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,243 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 181,708 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-15 17:31:12
合計ジャッジ時間 3,483 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
	int N; cin >> N;
	vector<int> A(N),B(N);
	rep(i,N) cin >> A[i];
	rep(i,N) cin >> B[i];

	vector<vector<bool>> win(N, vector<bool>(N,false));
	rep(i,N) {
		rep(j,N) {
			if (A[i] > B[j]) win[i][j] = true;
		}
	}

  vector<int> u(N),v(N);
	rep(i,N) u[i] = i;
  
	int q,r;
	q = r = 0;
	do {
		rep(i,N) v[i] = i;
    do {
      int p = 0;
      rep(i,N) {
				if (win[u[i]][v[i]]) p++;
			}
			if (2*p > N) q++;
			r++;
		} while (next_permutation(all(v)));
	} while (next_permutation(all(u)));
	
	cout << fixed << setprecision(10) << double(q) / double(r) << endl;
}
0