結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2019-04-11 21:06:51 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,436 bytes |
コンパイル時間 | 1,166 ms |
コンパイル使用メモリ | 161,904 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-19 08:50:29 |
合計ジャッジ時間 | 1,963 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define ll long long#define REP(i,x) for(int i=0;i<(int)(x);i++)#define REPS(i,x) for(int i=1;i<=(int)(x);i++)#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)#define RREPS(i,x) for(int i=((int)(x));i>0;i--)const ll mod = 1e9 + 7;typedef pair<int,int> PI;typedef pair<ll,ll> PL;typedef vector<PI> vip;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<ll> vl;typedef vector<vl> vvl;int fact(int k){return k==0 ? 1 : k * fact(k-1);}int main (){cin.tie(0);ios::sync_with_stdio(false);int n;cin >> n;vi a(n);vi b(n);REP(i,n) {cin >> a[i];}REP(i,n) {cin >> b[i];}int perm = fact(n);float won = 0;for(int i = 0; i < perm; i++){//かつ回数数えるREP(j,perm){int count = 0;int cont = 0;REP(d,n){if(a[d] - b[d] > 0){count++;}if(a[d] - b[d] < 0){cont++;}}if(count > cont) won++;next_permutation(b.begin(), b.end());}next_permutation(a.begin(), a.end());}perm *= perm;float ans = won / perm;cout << ans << endl;return 0;}