結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2015-12-04 01:12:52 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,071 bytes |
コンパイル時間 | 636 ms |
コンパイル使用メモリ | 65,232 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 03:40:53 |
合計ジャッジ時間 | 1,339 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <iostream>#include <vector>using namespace std;typedef long long int64;vector<int> a;vector<int> b;vector<bool> fa;vector<bool> fb;int n;int64 process(int w, int ni){if(ni == 0){if(w > n / 2)return 1;return 0;}int64 res = 0;int bw = w;for(int i = 0; i < n; i++){if(fa[i])continue;fa[i] = true;for(int j = 0; j < n; j++){if(fb[j])continue;if(a[i] > b[j])w++;fb[j] = true;res += process(w, ni - 1);fb[j] = false;w = bw;}fa[i] = false;}return res;}int main(void){cin >> n;a.resize(n);b.resize(n);fa.resize(n, 0);fb.resize(n, 0);for(int i = 0; i < n; i++)cin >> a[i];for(int i = 0; i < n; i++)cin >> b[i];int64 p = 1;for(int i = 1; i <= n; i++)p *= i;cout << (double)process(0, n) / (p * p) << endl;return 0;}