結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー | 👑  potato167 | 
| 提出日時 | 2020-12-08 14:49:41 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 629 bytes | 
| コンパイル時間 | 1,360 ms | 
| コンパイル使用メモリ | 173,512 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-09-17 14:39:52 | 
| 合計ジャッジ時間 | 2,080 ms | 
| ジャッジサーバーID (参考情報) | judge6 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll I=167167167167;
ll Q=1e9+7;
int main() {
	int N,A=1,L=0;
	cin>>N;
	vector<ll> a(N);
	vector<ll> b(N);
	for(int i=0;i<N;i++) cin>>a[i];
	for(int i=0;i<N;i++) cin>>b[i],A*=(i+1);
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	for(int i=0;i<A;i++){
		vector<ll> p=b;
		for(int j=0;j<A;j++){
			ll Z=0;
			for(int k=0;k<N;k++){
				if(a[k]>p[k]) Z++;
				if(a[k]<p[k]) Z--;
			}
			if(Z>0) L++;
			next_permutation(p.begin(),p.end());
		}
		next_permutation(a.begin(),a.end());
	}
	long double X=A*A,Y=L;
	cout<<fixed<<setprecision(15);
	cout<<Y/X<<endl;
}
            
            
            
        