結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2021-08-15 06:44:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 671 bytes |
コンパイル時間 | 1,602 ms |
コンパイル使用メモリ | 170,764 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-06 16:37:02 |
合計ジャッジ時間 | 2,150 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>#define NIL (-1)#define ll long long#define all(x) (x).begin(),(x).end()using namespace std;const double PI = acos(-1.0);int main() {int N;cin >> N;vector<int> A(N), B(N);for (int i = 0; i < N; i++) cin >> A[i];for (int i = 0; i < N; i++) cin >> B[i];vector<int> a(N), b(N);for (int i = 0; i < N; i++) a[i] = b[i] = i;int ret = 0;int tot = 0;do {do {tot++;int co = 0;for (int i = 0; i < N; i++) {if (A[a[i]] > B[b[i]]) co++;}if (co * 2 > N) ret++;} while (next_permutation(all(b)));} while (next_permutation(all(a)));cout << fixed << setprecision(10) << (double)ret / tot << endl;}