結果
| 問題 |
No.133 カードゲーム
|
| コンテスト | |
| ユーザー |
ms ms
|
| 提出日時 | 2020-04-14 20:12:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,190 bytes |
| コンパイル時間 | 1,779 ms |
| コンパイル使用メモリ | 176,296 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-01 18:07:49 |
| 合計ジャッジ時間 | 3,005 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 6 WA * 13 |
ソースコード
#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;
}
ms ms