結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2019-11-12 19:30:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,419 bytes |
コンパイル時間 | 1,820 ms |
コンパイル使用メモリ | 172,092 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 06:35:46 |
合計ジャッジ時間 | 2,132 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
//http://rsujskf.s602.xrea.com/?yukicoder_133 //参考にさせて頂いた解説 #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll LongINF=1e13+7; const int dx[]={0,1,0,-1}; const int dy[]={1,0,-1,0}; 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, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);} void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない #define rep(i,n) for(int i=0;i<(n);i++) int main(){ int N,win=0,all=0; cin>>N; vector<int> A(N); vector<int> B(N); vector<int> ind(N); rep(i,N)cin>>A[i]; rep(i,N)cin>>B[i]; rep(i,N)ind[i]=i; do{ int a=0; rep(i,N){//ある一つのカードの出し方での、勝った回数をカウント if(A[ind[i]]>B[i])a++; if(A[ind[i]]<B[i])a--; } if(a>0)win++;//Bとのジャンケンに勝っていれば、 all++; }while(next_permutation(ind.begin(),ind.end())); cout<<double(win)/all<<endl; return 0; } //a=97,z=122 //next_permutationによって順列を全列挙できる!!! //ただ、計算量的問題で出番は少ない?