結果

問題 No.133 カードゲーム
ユーザー ms msms ms
提出日時 2020-04-14 20:26:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,358 bytes
コンパイル時間 1,969 ms
コンパイル使用メモリ 174,444 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 18:07:49
合計ジャッジ時間 2,838 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int N;
vector<int> A, B;
vector<vector<int>> PERM1, PERM2;

int CMP(int a, int b){
	int cntA = 0, cntB = 0;
	rep(i,N){
		int numA = PERM1[a][i];
		int numB = PERM2[b][i];
		if(numA > numB) cntA++;
		else cntB++;
	}

	return (cntA > cntB) ? 1:0;
}

void PRINT(vector<int> P, int num){
	cout  << "SHOW" << num << ": ";
	rep(i,P.size()){
		cout << P[i] << " "; 
	}
	cout << endl;
}

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

	sort(A.begin(),A.end());
	sort(B.begin(),B.end());

	do{
		PERM1.pb(A);
		//PRINT(A,1);
	}while(next_permutation(A.begin(),A.end()));

	do{
		PERM2.pb(B);
		//PRINT(B,2);
	}while(next_permutation(B.begin(),B.end()));


	int cnt = 0;
	rep(a,PERM1.size()){
		rep(b,PERM2.size()){
			cnt += CMP(a,b);
		}
	}
	double P = (double)(cnt) / ((double)(PERM1.size()) * (double)(PERM2.size()));
	cout << P << endl;
}
0