結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2018-08-11 10:38:38 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 980 bytes |
コンパイル時間 | 414 ms |
コンパイル使用メモリ | 55,152 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-23 06:07:53 |
合計ジャッジ時間 | 1,268 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <iostream>#include <cstring>using namespace std;typedef long long ll;ll n, a[6], b[6], c[6], d[6];double res;bool e[6], f[6];void dfs(ll x){if (x == n * 2) {ll A = 0, B = 0;for (ll i = 0; i < n; i++) {if (c[i] > d[i]) A++;if (c[i] < d[i]) B++;}if (A > B) res++;} else if (x < n) {for (ll i = 0; i < n; i++) {if (e[i]) continue;c[x] = a[i];e[i] = true;dfs(x + 1);e[i] = false;}} else {for (ll i = 0; i < n; i++) {if (f[i]) continue;d[x - n] = b[i];f[i] = true;dfs(x + 1);f[i] = false;}}}int main(void){// Your code here!cin >> n;for (ll i = 0; i < n; i++) cin >> a[i];for (ll i = 0; i < n; i++) cin >> b[i];dfs(0);for (ll i = 2; i <= n; i++) res /= i * i;cout << res << endl;}