結果

問題 No.133 カードゲーム
ユーザー sansaqua
提出日時 2019-05-05 13:55:43
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,044 bytes
コンパイル時間 720 ms
コンパイル使用メモリ 73,784 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-24 21:41:39
合計ジャッジ時間 1,500 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
int main() {
int n;
std::cin >> n;
std::vector<int> indices1(n);
std::vector<int> indices2(n);
std::iota(indices1.begin(), indices1.end(), 0);
std::vector<int> cardsA(n);
std::vector<int> cardsB(n);
for (auto& e : cardsA) {
std::cin >> e;
}
for (auto& e : cardsB) {
std::cin >> e;
}
int fact = 1;
for (int i = 1; i <= n; i++) {
fact *= i;
}
int total = fact * fact;
int win = 0;
do {
std::iota(indices2.begin(), indices2.end(), 0);
do {
int a = 0;
int b = 0;
for (int i = 0; i < n; i++) {
if (cardsA[indices1[i]] > cardsB[indices2[i]]) {
a++;
} else if (cardsA[indices1[i]] < cardsB[indices2[i]]) {
b++;
}
}
if (a > b) {
win++;
}
} while (std::next_permutation(indices2.begin(), indices2.end()));
} while (std::next_permutation(indices1.begin(), indices1.end()));
float ans = (float) win / total;
std::cout << ans << std::endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0