結果

問題 No.133 カードゲーム
ユーザー ninoinui
提出日時 2020-11-23 16:11:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,043 bytes
コンパイル時間 2,362 ms
コンパイル使用メモリ 203,360 KB
最終ジャッジ日時 2025-01-16 05:05:41
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template <typename T, typename U> bool cmin(T &a, U b) { return a > b && (a = b, true); }
template <typename T, typename U> bool cmax(T &a, U b) { return a < b && (a = b, true); }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<int> B(N);
  for (int i = 0; i < N; i++) cin >> B.at(i);

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  vector<vector<int>> V;
  do {
    V.push_back(B);
  } while (next_permutation(B.begin(), B.end()));

  int win = 0, lose = 0, draw = 0;
  do {
    for (auto tmp : V) {
      int x = 0, y = 0;
      for (int i = 0; i < N; i++) {
        if (A.at(i) > tmp.at(i)) x++;
        else if (A.at(i) < tmp.at(i)) y++;
      }
      if (x > y) win++;
      else if (x < y) lose++;
      else draw++;
    }
  } while (next_permutation(A.begin(), A.end()));

  cout << fixed << setprecision(6) << (double)win / (win + lose + draw) << "\n";
}
0