結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2019-02-11 23:55:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,010 ms / 5,000 ms |
コード長 | 638 bytes |
コンパイル時間 | 831 ms |
コンパイル使用メモリ | 92,068 KB |
最終ジャッジ日時 | 2025-01-06 21:07:56 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:21:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%zu", &N); | ~~~~~^~~~~~~~~~~ main.cpp:24:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 24 | for (auto& ai: A) scanf("%d", &ai); | ~~~~~^~~~~~~~~~~ main.cpp:25:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | for (auto& bi: B) scanf("%d", &bi); | ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio> #include <vector> #include <algorithm> #include <random> std::mt19937 rsk(0315); bool wins(std::vector<int>& A, std::vector<int> &B) { std::shuffle(A.begin(), A.end(), rsk); std::shuffle(B.begin(), B.end(), rsk); size_t N = A.size(); int a = 0; int b = 0; for (size_t i = 0; i < N; ++i) ++((A[i] > B[i])? a:b); return a > b; } int main() { size_t N; scanf("%zu", &N); std::vector<int> A(N), B(N); for (auto& ai: A) scanf("%d", &ai); for (auto& bi: B) scanf("%d", &bi); int win = 0; for (int i = 0; i < 10000000; ++i) if (wins(A, B)) ++win; printf("%.6f\n", win*1e-7); }