結果
問題 | No.133 カードゲーム |
ユーザー | morimario |
提出日時 | 2021-02-08 08:59:05 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 3,938 bytes |
コンパイル時間 | 4,371 ms |
コンパイル使用メモリ | 264,404 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-05 05:21:27 |
合計ジャッジ時間 | 5,091 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,948 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 1 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,944 KB |
testcase_17 | AC | 2 ms
6,944 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,944 KB |
testcase_22 | AC | 2 ms
6,944 KB |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pil = pair<int, ll>; using pli = pair<ll, int>; template <typename T> using piT = pair<int, T>; template <typename T> using pTi = pair<T, int>; template <typename T> using pTT = pair<T, T>; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using pll = pair<ll, ll>; using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>; using pbb = pair<bool, bool>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>; using pcc = pair<char, char>; using vc = vector<char>; using vvc = vector<vc>; using vvvc = vector<vvc>; using pss = pair<string, string>; using vs = vector<string>; using vvs = vector<vs>; using vvvs = vector<vvs>; using pdd = pair<double, double>; using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>; #define rep0(times) for(int counter = 0; counter < (int)(times); ++counter) #define rep(counter, goal) for (int counter = 0; counter < (int)(goal); ++counter) #define rep2(counter, start, goal) for (int counter = (int)(start); counter < (int)(goal); ++counter) #define rep3(counter, start, goal) for (int counter = (int)(start); counter > (int)(goal); --counter) #define all(container) begin(container), end(container) template <typename T> bool chmax(T &x, const T &y) { if (x < y) { x = y; return true; } return false; } template <typename T> bool chmin(T &x, const T &y) { if (x > y) { x = y; return true; } return false; } void Yn(bool flag) { cout << (flag ? "Yes" : "No") << "\n"; } void yn(bool flag) { cout << (flag ? "yes" : "no") << "\n"; } void YN(bool flag) { cout << (flag ? "YES" : "NO") << "\n"; } void set_prec(const int &digits) { cout << fixed << setprecision(digits); cerr << fixed << setprecision(digits); } #include <atcoder/all> using namespace atcoder; void pr(const atcoder::modint1000000007 &obj) { cerr << obj.val(); }; void pr(const atcoder::modint998244353 &obj) { cerr << obj.val(); }; void pr(const atcoder::modint &obj) { cerr << obj.val(); }; template <typename T> void pr(const T &obj) { cerr << obj; } template <typename T, typename ...Ts> void pr(const T &first, const Ts &...rest) { pr(first); pr(", "); pr(rest...); } template <typename S, typename T> void pr(const pair<S, T> &pair) { pr("("); pr(pair.first); pr(", "); pr(pair.second); pr(")"); } template <typename T> void pr(const vector<T> &vec) { pr("{"); for (T obj : vec) { pr(obj); pr(", "); } pr("}"); } template <typename T> void pr(const vector<vector<T>> &vv) { pr("\n"); rep(index, vv.size()) { pr("["); pr(index); pr("]: "); pr(vv[index]); pr("\n"); } } template <typename T> void pr(const set<T> &vec) { pr("{"); for (T obj : vec) { pr(obj); pr(", "); } pr("}"); } template <typename S, typename T> void pr(const map<S, T> &map) { pr("{"); for (pair<S, T> pair : map) { pr("("); pr(pair.first); pr(": "); pr(pair.second); pr("), "); } pr("}"); } #define db(obj) cerr << #obj << ": "; pr(obj); cerr << " " #define dl(obj) db(obj); cerr << "\n"; #define dm(...) cerr << "(" << #__VA_ARGS__ << "): ("; pr(__VA_ARGS__); cerr << ") " #define dml(...) dm(__VA_ARGS__); cerr << "\n" // const ll MOD = 1000000007; // using mint = modint1000000007; // const ll MOD = 998244353; // using mint = modint998244353; // using mint = modint; vi A_cards, B_cards; int A_wins = 0; void permutation(int n) { assert(n >= 0); vi p; rep(i, n) p.push_back(i); do { int A_point = 0, B_point = 0; rep(j, n) { if (A_cards[j] > B_cards[p[j]]) ++A_point; else if (A_cards[j] < B_cards[p[j]]) ++B_point; } if (A_point > B_point) ++ A_wins; } while (next_permutation(all(p))); } int main() { int N; cin >> N; A_cards = B_cards = vi(N); rep(i, N) cin >> A_cards[i]; rep(i, N) cin >> B_cards[i]; permutation(N); double ans = A_wins; rep2(i, 1, N + 1) ans /= i; cout << ans << endl; }