結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2022-12-15 09:02:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 5,000 ms |
コード長 | 3,172 bytes |
コンパイル時間 | 1,928 ms |
コンパイル使用メモリ | 197,588 KB |
最終ジャッジ日時 | 2025-02-09 13:43:58 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;using C = complex<double>;const int mod = 998244353;const long long LINF = 1001002003004005006;const int INF = 1001001001;const double PI = acos(-1);const double EPS = 1e-10;const int di[4] = {-1,0,1,0};const int dj[4] = {0,-1,0,1};const int dx[8] = {1,1,1,0,0,-1,-1,-1};const int dy[8] = {1,0,-1,1,-1,1,0,-1};# define sz(x) (int)(x).size()# define rsz(x,n) x.resize(n)# define yosupo(x) {cout << (x) << endl; return 0;}# define ll long long# define fi first# define se second# define pb push_back# define pf push_front# define eb emplace_back# define ef emplace_front# define pob pop_back# define pof pop_front# define GET_MACRO(_1, _2, _3, NAME, ...) NAME# define _rep(i, n) _rep2(i, 0, n)# define _rep2(i, a, b) for(int i = (int)(a); i < (int)(b); i++)# define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)# define srep(i, a, b) for(int i = a; i <= b; ++i)# define all(obj) (obj).begin(), (obj).end()# define rall(obj) (obj).rbegin(), (obj).rend()inline void YesNo(bool f) { std::cout << (f? "Yes": "No") << std::endl; }void read() {}template <typename T, class... U> void read(T &t, U &...u) { cin >> t; read(u...); }void writeln() { cout << endl; }template <typename T, class... U, char sep = ' '> void writeln(const T &t, const U &...u) { cout << t; if (sizeof...(u)) cout << sep; writeln(u...);}# define Pll pair<ll, ll># define P pair<int,int># define bit(x,i) (((x) >> (i)) & 1)# define equals(a, b) (fabs((a) - (b)) < EPS) // 誤差を考慮した同値判定template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,v.size())i>>v[j];return i;}template<typename T>string join(vector<T>&v){stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}template<typename T>ostream& operator<<(ostream&o,vector<T>&v){if(v.size())o<<join(v);return o;}template<typename T>ostream& operator<<(ostream&o,vector<vector<T>>&vv){if(vv.size())o<<join(vv);return o;}template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << "P(" << p.first << " " << p.second << ")";}template<typename T> using vc = vector<T>;template<typename T> using vv = vc<vc<T>>;using vi = vc<int>; using vvi = vv<int>;using vl = vc<ll>; using vvl = vv<ll>;void solve() {int n;read(n);vi a(n), b(n);rep(i,n) read(a[i]);rep(i,n) read(b[i]);vi perm1(n), perm2(n);iota(all(perm1),0);iota(all(perm2),0);int cnt = 0, tot = 0;do{do{int cntA = 0, cntB = 0;rep(i,n) {if(a[perm1[i]] > b[perm2[i]]) cntA++;else cntB++;}if(cntA > cntB) cnt++;tot++;}while(next_permutation(all(perm2)));}while(next_permutation(all(perm1)));double ans = (double)cnt/tot;printf("%.10lf\n", ans);}int main() {int tt = 1;//read(tt);while(tt--) {solve();}}