結果

問題 No.133 カードゲーム
ユーザー どりみあんどりみあん
提出日時 2019-11-12 19:30:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,419 bytes
コンパイル時間 1,635 ms
コンパイル使用メモリ 173,140 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 10:25:28
合計ジャッジ時間 2,535 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 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 #

//http://rsujskf.s602.xrea.com/?yukicoder_133
//参考にさせて頂いた解説
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
    int N,win=0,all=0;
    cin>>N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> ind(N);
    rep(i,N)cin>>A[i];
    rep(i,N)cin>>B[i];
    rep(i,N)ind[i]=i;
    do{
        int a=0;
        rep(i,N){//ある一つのカードの出し方での、勝った回数をカウント
            if(A[ind[i]]>B[i])a++;
            if(A[ind[i]]<B[i])a--;
        }
        if(a>0)win++;//Bとのジャンケンに勝っていれば、
        all++;
    }while(next_permutation(ind.begin(),ind.end()));
    cout<<double(win)/all<<endl;
    return 0;
}

//a=97,z=122
//next_permutationによって順列を全列挙できる!!!
//ただ、計算量的問題で出番は少ない?
0