結果

問題 No.133 カードゲーム
ユーザー hiroahiroa
提出日時 2019-12-07 11:35:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 710 bytes
コンパイル時間 3,525 ms
コンパイル使用メモリ 166,896 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 06:01:44
合計ジャッジ時間 2,657 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
	int N;
	cin>>N;
	vector<int> A(N);
	vector<int> B(N);
	rep(i,N) cin>>A[i];
	rep(i,N) cin>>B[i];

	vector<int> NA(N),NB(N);
	rep(i,N) NA[i]=NB[i]=i;

	int ok=0,count=0;

	do{
		do{
			int win=0;
			rep(i,N){
				if(A[NA[i]]>B[NB[i]]) win++;
				else win--;
			}
			if(win>0) ok++;
			count++;
		}while(next_permutation(all(NA)));
	}while(next_permutation(all(NB)));

	cout<<setprecision(10)<<(double)ok/count<<endl;
}
0