結果

問題 No.133 カードゲーム
ユーザー 永田伸広永田伸広
提出日時 2022-11-13 13:57:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 2,339 bytes
コンパイル時間 1,974 ms
コンパイル使用メモリ 111,620 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 22:54:12
合計ジャッジ時間 2,585 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//include
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<math.h>
#include<queue>
#include<functional>
#include<set>
#include<bitset>
#include<stack>
#include<string>
#include<sstream>
#include<regex>
//using
using namespace std;
//型定義
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> lpr;
typedef vector<vector<ll>> Graph;
//イテレーション
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORE(i,I) for(const auto& i:I)
//x:コンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
//#define MOD 1000000007 //問題による
#define MOD 998244353
//略記
#define F first
#define S second
//出力(空白区切りで昇順に)
#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()<<endl;
//aをbで割る時の繰上げ,繰り下げ
ll myceil(ll a,ll b){return (a+(b-1))/b;}
ll myfloor(ll a,ll b){return a/b;}
//盤面上で進む方向
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
// int dx[4] = {1, -1};
// int dy[4] = {1, -1};
// int dx[8] = {1, 1, 1, 0,0,-1,-1,-1};
// int dy[8] = {0, 1, -1, 1,-1,0,1,-1};
//斜め
// int dx[2] = {1,-1};
// int dy[2] = {1,-1};
//小数の桁数の出力指定
//cout<<fixed<<setprecision(10);
//入力の高速化用のコード
//ios::sync_with_stdio(false);
//cin.tie(nullptr);
double PI=3.14159265358979;

int main(){
    ll N; cin >> N;
    vector<ll> A(N),B(N); 
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    sort(ALL(A));
    sort(ALL(B));
    ll matchcnt=0,wincnt=0;
    do{
        do{
            matchcnt++;
            ll tempA=0,tempB=0;
            REP(i,N){
                if(A[i]>B[i]){
                    tempA++;
                }
                else if(A[i]<B[i]){
                    tempB++;
                }
            }
            if(tempA>tempB) wincnt++;
        }while(next_permutation(ALL(B)));
    }while(next_permutation(ALL(A)));
    cout << fixed << setprecision(10) <<double(wincnt)/double(matchcnt) << endl;
}
0