結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2020-03-25 15:41:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,060 bytes |
コンパイル時間 | 1,319 ms |
コンパイル使用メモリ | 164,284 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-01 23:54:59 |
合計ジャッジ時間 | 2,331 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>#define rep(i,n) for(int i = 0; i < (int)(n); i++)using namespace std;using ll = long long;template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}int main() {int n;cin >> n;vector<int> a(n), b(n), permA(n), permB(n);rep(i, n) cin >> a[i];rep(i, n) cin >> b[i];int tot = 0;int win = 0;iota(permA.begin(), permA.end(), 0);do {iota(permB.begin(), permB.end(), 0);do {tot++;int cur_win = 0;rep(i, n) {int cur_a = a[permA[i]];int cur_b = b[permB[i]];if (cur_a > cur_b) cur_win++;}int cur_lose = n - cur_win;if (cur_win > cur_lose) win++;} while (next_permutation(permB.begin(), permB.end()));} while (next_permutation(permA.begin(), permA.end()));double ans = (double)win / tot;cout << ans << endl;}