結果
問題 |
No.133 カードゲーム
|
ユーザー |
![]() |
提出日時 | 2020-03-11 16:13:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,755 bytes |
コンパイル時間 | 1,689 ms |
コンパイル使用メモリ | 172,752 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 00:18:43 |
合計ジャッジ時間 | 2,607 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i=0; i<(int)(n); i++) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using Graph = vector<vector<int>>; const ll MOD = 1000000007; const ll INF = 10000000000000000; vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1}; vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1}; template<class T> struct edge { int from, to; T cost;}; 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> inline T powerM(T a,T b){if (b==0) return 1; T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; } template<class T> inline T power(T a,T b,T m){ if (b==0) return 1; T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; } template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);} template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;} // ax+by=gcd(a,b)を解く template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;} int main() { int n; cin >>n; vector<int> a(n),b(n); rep(i, n) cin >>a.at(i); rep(i, n) cin >>b.at(i); int win = 0; int games = 0; vector<int> v(n); rep(i, n) v[i] = i; sort(all(v)); do { int awin = 0; int bwin = 0; for (int i=0; i<n; i++){ int carda = a[v[i]], cardb = b[i]; if (carda > cardb) awin++; if (carda < cardb) bwin++; } games++; if (awin > bwin) win++; } while (next_permutation(all(v))); double res = (double)win / (double)games; cout <<res <<endl; }