結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2019-12-16 10:44:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,243 bytes |
コンパイル時間 | 2,267 ms |
コンパイル使用メモリ | 183,888 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 19:40:27 |
合計ジャッジ時間 | 3,249 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#pragma GCC optimize("Ofast")#include <bits/stdc++.h>using namespace std;typedef long long ll;#define EPS (1e-7)#define INF (1e9)#define rep(i, n) for(int i = 0; i < (int)(n); i++)#define all(x) x.begin(),x.end()const double PI = acos(-1);const ll MOD = 1000000007;template<class T>inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}template<class T>inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}///////////////////////////////////////////////////////////////int main() {ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化int N; cin >> N;vector<int> A(N),B(N);rep(i,N) cin >> A[i];rep(i,N) cin >> B[i];vector<vector<bool>> win(N, vector<bool>(N,false));rep(i,N) {rep(j,N) {if (A[i] > B[j]) win[i][j] = true;}}vector<int> u(N),v(N);rep(i,N) u[i] = i;int q,r;q = r = 0;do {rep(i,N) v[i] = i;do {int p = 0;rep(i,N) {if (win[u[i]][v[i]]) p++;}if (2*p > N) q++;r++;} while (next_permutation(all(v)));} while (next_permutation(all(u)));cout << fixed << setprecision(10) << double(q) / double(r) << endl;}