結果

問題 No.133 カードゲーム
ユーザー ppp-skyblueppp-skyblue
提出日時 2022-11-15 02:20:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 3,904 bytes
コンパイル時間 4,529 ms
コンパイル使用メモリ 264,004 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-14 08:58:01
合計ジャッジ時間 5,915 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,356 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
// using mint = modint1000000007;
// using mint = modint998244353;
typedef long long ll;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define nrep(i,n) for (int i = 1; i <= (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define pop_count(x) __builtin_popcountll(x)
using P = pair<int,int>;
#define INF 1001001001
#define LINF ((1LL<<61)-1)
#define endl "\n"
#define exist(v, x) ((v).find(x) != v.end())
#define argsort(v) sort(xy.begin(), xy.end(), [](const auto &p1, const auto &p2) { return atan2l(p1.second, p1.first) < atan2l(p2.second, p2.first);})
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(a>b){ a=b; return 1; } return 0; }
/* DEBUG */
#define debug_bar cerr << "\033[36m" << "----------------------------------------\n" << "\033[m";
#define debug_header cerr << "\033[36m" << "[" << __FUNCTION__ << ":" << __LINE__ << "] " << "\033[m";
#define debug(...) do { debug_header; cerr << "\033[36m" << #__VA_ARGS__ << " = "; view(__VA_ARGS__); cerr << '\n' << "\033[m"; } while (0)
#define debug2(vv) do { debug_header; cerr << "\033[36m" << #vv << " = [\n"; view2d(vv); cerr << "  ]\n" << "\033[m"; } while (0)
#define debug3(vvv) do { debug_header; cerr << "\033[36m" << #vvv << " = [\n"; view3d(vvv); cerr << "  ]\n" << "\033[m"; } while (0)
void view() {}
void view(const ll& a) { if (abs(a) == LINF) { cerr << "+-"[signbit(a)] << "LINF"; } else { cerr << a; } }
template<class T> void view(const T& a) { cerr << a; }
template<class T> void view(const vector<T>& v){ cerr << "["; for (int i = 0; i < (int)v.size(); i++) { if (i) { cerr << ", "; } view(v[i]); } cerr << "]"; }
template<class T> void view(const vector<vector<T>>& vv){ cerr << "["; for (int i = 0; i < (int)vv.size(); i++) { if (i) { cerr << ", "; } view(vv[i]); } cerr << "]"; }
template<class K, class V> void view(const map<K, V>& mp){ cerr << "["; for (auto it = mp.begin(); it != mp.end(); it++) { if (it != mp.begin()) { cerr << ", "; } cerr << "("; view(it->first); cerr << ", "; view(it->second); cerr << ")"; } cerr << "]"; }
template<class T> void view2d(const vector<vector<T>>& vv){ for (int i = 0; i < (int)vv.size(); i++) { cerr << "    "; view(vv[i]); cerr << ",\n"; } }
template<class T> void view3d(const vector<vector<vector<T>>>& vvv) { for (int i = 0; i < (int)vvv.size(); i++) { for (int j = 0; j < (int)vvv[i].size(); j++) { cerr << "    " << " ["[j == 0]; view(vvv[i][j]); if (j == (int)vvv[i].size() - 1) { cerr << "]"; } cerr << ",\n"; } if (i < (int)vvv.size() - 1) { cerr << "\n"; } } }
/* 出力 */
// template <typename T> inline void print(const vector<T>& v, string s = " ") { rep(i, v.size()) cout << v[i] << (i != (int)v.size()-1 ? s : "\n"); }
template <typename T> inline void print(const vector<T>& v, string s = " ") { rep(i, v.size()) cout << v[i] << (i != (int)v.size()-1 ? s : " \n"); }
template <typename T, typename S> inline void print(const pair<T, S>& p) { cout << p.first << " " << p.second << endl; }
template <typename T> inline void print(const T& x) { cout << x << "\n"; }
inline void print(double x) { printf("%.15f\n", x); }
inline void print(bool x) { cout << (x ? "Yes" : "No") << "\n"; }

int32_t main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  vector<int> b(n);
  rep(i, n) cin >> b[i];
  sort(all(b));
  double ans = 0;
  double cnt = 0;
  do {
    do {
      cnt += 1;
      int nowa = 0, nowb = 0;
      rep(i, n) {
        if(a[i] > b[i]) nowa++;
        else if(a[i] < b[i]) nowb++;
      }
      if(nowa > nowb) ans += 1;
    } while(next_permutation(all(b)));
  } while(next_permutation(all(a)));
  print(ans / cnt);
}
0