結果

問題 No.133 カードゲーム
ユーザー pleiades_223pleiades_223
提出日時 2023-03-14 18:40:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 2,962 bytes
コンパイル時間 7,815 ms
コンパイル使用メモリ 263,120 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 11:58:29
合計ジャッジ時間 5,361 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vcc = vector<char>;
using vvcc = vector<vcc>;
using mii = map<int,int>;
using mll = map<ll,ll>;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); i++)
#define rreps(i, a, n) for (ll i = (a); i >= (ll)(n); i--)
#define rep(i, n) reps(i, 0, n)
#define repd(i, n) reps(i, 1, n + 1)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rrepd(i,n) for(ll i=n;i>=1;i--)
#define vrep(i,x) for(auto i:x)
#define vsrep(i,x) for(auto &i:x)
#define vinsert(x,a) x.insert(upper_bound(x.begin(),x.end(),a),a)
#define vin(x) rep(i,x.size())cin >> x[i];
#define vout(x) rep(i,x.size())cout << x[i] << ( i!=x.size()-1 ? ' ' : '\n' );
template<typename T> auto vec_sum(T x){ll ans=0;rep(i,x.size())ans+=x[i];return ans;}
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end());
template<typename T> void yesno(T x){if(x)cout << "Yes" << endl;else cout << "No" << endl;}
template<typename T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<typename T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
#define F first
#define S second
template<typename T> using vc = vector<T>;
template<typename T> using vvc = vector<vector<T>>;
template<typename T,typename Y> using uomap = unordered_map<T,Y>;
template<typename T> using uoset = unordered_set<T>;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int ddx[8] = { -1,0,1,1,1,0,-1,-1 };
int ddy[8] = { 1,1,1,0,-1,-1,-1,0 };
string taka="Takahashi",aoki="Aoki";
const int inf = 1073741824;//2^30
const ll llinf = 1152921504606846976;//2^60
const long double lpi = 3.141592653589793238;
const double pi = 3.141592653589793;
//ll mod = 1000000007;
//ll mod = 998244353;
//using mint = modint1000000007;
//using mint = modint998244353;

int main(){
    cout << fixed << setprecision(16);
    //ifstream in("input.txt");
    //cin.rdbuf(in.rdbuf());
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    cin >> n;
    string stra="",strb="";
    rep(i,n){
        stra+=('0'+i);
        strb+=('0'+i);
    }
    vi va(n),vb(n);
    vin(va);vin(vb);
    int cnta=0,cntb=0;
    do{
        do{
            int a,b;
            a=b=0;
            rep(i,n){
                if(va[stra[i]-'0']>vb[strb[i]-'0'])a++;
                else b++;
            }
            if(a>b)cnta++;
            else cntb++;
        }while(next_permutation(all(strb)));
    }while(next_permutation(all(stra)));
    cout << (double)cnta/(cnta+cntb) << endl; 
}
0