結果

問題 No.133 カードゲーム
ユーザー misora192misora192
提出日時 2020-06-16 23:38:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 902 bytes
コンパイル時間 1,464 ms
コンパイル使用メモリ 170,556 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-03 12:02:03
合計ジャッジ時間 2,260 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<int> a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];

	double won = 0.0;
	double tot = 0.0;

	vector<int> v(n), w(n);
	rep(i, n){
		v[i] = i;
		w[i] = i;
	}

	do{
		do{
			tot++;
			int acnt = 0, bcnt = 0;
			rep(i, n){
				if(a[v[i]] > b[w[i]]) acnt++;
				if(a[v[i]] < b[w[i]]) bcnt++;
			}

			if(acnt > bcnt) won++;
		}while(next_permutation(v.begin(), v.end()));
	}while(next_permutation(w.begin(), w.end()));

	cout << fixed << setprecision(10);
	cout << won / tot << endl;
}
0