結果

問題 No.133 カードゲーム
ユーザー face4face4
提出日時 2018-05-13 16:16:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 2,118 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 72,640 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 18:52:06
合計ジャッジ時間 1,590 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
    int n, A[4], B[4];
    cin >> n;
    for(int i = 0; i < n; i++)  cin >> A[i];
    for(int i = 0; i < n; i++)  cin >> B[i];
    sort(A, A+n);
    sort(B, B+n);
    
    int m = 0;
    int c = 0;
    do{
        do{
            m++;
            int wins = 0;
            for(int i = 0; i < n; i++){
                if(A[i] > B[i]) wins++;
            }
            if(wins > n-wins)   c++;
        }while(next_permutation(B, B+n));
    }while(next_permutation(A, A+n));

    cout << (double)c / m << endl;
    return 0;
}
/*
vector<string> va;
vector<string> vb;

bool check(string s , string t){
    int awin = 0, bwin = 0;
    for(int i = 0; i < s.length(); i++){
        int a = s[i]-'0';
        int b = t[i]-'0';
        if(a > b)   awin++;
        else if(a < b)  bwin++;
    }

    return awin>bwin;
}

void makePermA(string s, string t){
    if(s == "")     va.push_back(t);
    else{
        for(int i = 0; i < s.size(); i++){
            string tmps = s;
            string tmpt = t+tmps[i];
            tmps.erase(tmps.begin()+i);
            makePermA(tmps , tmpt);
        }
    }
}

void makePermB(string s, string t){
    if(s == "")     vb.push_back(t);
    else{
        for(int i = 0; i < s.size(); i++){
            string tmps = s;
            string tmpt = t+tmps[i];   
            tmps.erase(tmps.begin()+i);
            makePermB(tmps , tmpt);
        }
    }
}

int main(){
    int n;
    string a, b, c;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> c;
        a += c;
    }

    for(int i = 0; i < n; i++){
        cin >> c;
        b += c;
    }

    makePermA(a, "");
    makePermB(b, "");

    int sum = 0;
    int win = 0;
    for(vector<string>::iterator ita = va.begin(); ita != va.end(); ita++){
        string first = *ita;
        for(vector<string>::iterator itb = vb.begin(); itb != vb.end(); itb++){
            string second = *itb;
            if(check(first, second)) win++;
            sum++;
        }
    }

    cout << (double)win / sum << endl;
    return 0;
}
*/
0