結果

問題 No.133 カードゲーム
ユーザー ms msms ms
提出日時 2020-04-14 20:12:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,190 bytes
コンパイル時間 2,143 ms
コンパイル使用メモリ 174,300 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 18:07:08
合計ジャッジ時間 2,986 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
6,944 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
6,940 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
6,944 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 cnt = 0;
	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;
}

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);
	}while(next_permutation(A.begin(),A.end()));

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

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