結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2019-12-31 02:58:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,172 bytes |
コンパイル時間 | 1,413 ms |
コンパイル使用メモリ | 168,884 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 04:06:19 |
合計ジャッジ時間 | 2,264 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define fi first #define se second #define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++) #define rep(i,n) repl(i,0,n) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<x<<endl #define mmax(x,y) (x>y?x:y) #define mmin(x,y) (x<y?x:y) #define maxch(x,y) x=mmax(x,y) #define minch(x,y) x=mmin(x,y) #define uni(x) x.erase(unique(all(x)),x.end()) #define exist(x,y) (find(all(x),y)!=x.end()) #define bcnt __builtin_popcountll #define INF 1e16 #define mod 1000000007 int main() { int N; cin >> N; vector<int> A(N); vector<int> B(N); for (int i = 0; i < N; i++) { cin >> A[i]; } for (int i = 0; i < N; i++) { cin >> B[i]; } vector<int> NA(N), NB(N); for (int i = 0; i < N; i++) { NA[i] = NB[i] = i; } int ok = 0; int count = 0; do{ do{ int win = 0; for (int i = 0; i < N; i++) { if (A[NA[i]] > B[NB[i]]) win++; else win--; } if (win > 0) ok++; count++; } while (next_permutation(NA.begin(), NA.end())); } while (next_permutation(NB.begin(), NB.end())); printf("%.14f\n", (double)ok / count); }