結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2020-04-25 20:51:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 3,050 bytes |
コンパイル時間 | 1,735 ms |
コンパイル使用メモリ | 176,680 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 19:45:30 |
合計ジャッジ時間 | 2,566 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>#include <regex>#ifdef _DEBUG#include "debug.h"#endif//#define int ll#define float double#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)#define REP(i, e) FOR(i, 0, e)#define all(v) (v).begin(),(v).end()#define mkpr make_pair#define mktp make_tuple#define tv(tp, i) get<(i)>(tp)#define CLEAR(obj) obj = decltype(obj)()#define var auto#define OUT(type) type &#define IN(type) const type &#define self (*this)#define in :#define True true#define False falseusing namespace std; using int32 = int32_t; using ll = long long; using ull = unsigned long long;using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;using vb = vector<bool>; using vvb = vector<vb>; using vc = vector<char>; using vvc = vector<vc>;using vf = vector<float>; using vvf = vector<vf>; using vd = vector<double>; using vvd = vector<vd>;using str = string; using vs = vector<string>;using pii = pair<int, int>; using pll = pair<ll, ll>; using pff = pair<float, float>; using pdd = pair<double, double>;using psl = pair<string, ll>; using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7; static const ll LINF = LLONG_MAX/2;#ifdef intstatic const int INF = LINF;#elsestatic const int INF = INT_MAX/2;#endifstatic double EPS = 1e-9;#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);#ifdef IMPORT_SAMPLE#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());#else#define DEBUG_IMPORT(file)#endifstatic inline int ord(char c) {return (int)c;}static inline char chr(int n) {return (char)n;}static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}static inline void EPR(str msg) {cerr << msg << endl;}static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}void permutation(OUT(vvi) perm, IN(vi) A){vi a = A;sort(a.begin(), a.end());do {vi pt;for (int i : a) pt.push_back(i);perm.push_back(pt);} while (next_permutation(a.begin(), a.end()));}int32 main(int32 argc, char* argv[]) {FASTCIN();DEBUG_IMPORT("sample-1");int N; cin>>N;vi A(N); REP(i,N) cin>>A[i];vi B(N); REP(i,N) cin>>B[i];vvi permA;permutation(permA, A);vvi permB;permutation(permB, B);int all = permA.size() * permB.size();//EPR("all: " + to_string(all));int winA = 0;for (vi pa in permA) {for (vi pb in permB) {int wa = 0, wb = 0;REP(i,N)if (pa[i] > pb[i])wa += 1;else if (pa[i] < pb[i])wb += 1;if (wa > wb) winA += 1;}}//EPR("winA: " + to_string(winA));double ans = winA/(double)all;//cout << ans << endl;printf("%.6lf", ans);return 0;}