結果

問題 No.133 カードゲーム
コンテスト
ユーザー pekempey
提出日時 2016-12-22 21:39:57
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 142 ms / 5,000 ms
コード長 548 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 944 ms
コンパイル使用メモリ 185,508 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-11 08:25:35
合計ジャッジ時間 4,124 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:20:31: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   20 |                 random_shuffle(a.begin(), a.end());
      |                 ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:63,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algo.h:4537:5: note: declared here
 4537 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
main.cpp:21:31: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   21 |                 random_shuffle(b.begin(), b.end());
      |                 ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algo.h:4537:5: note: declared here
 4537 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main() {
	srand(time(NULL));

	int n;
	cin >> n;

	vector<int> a(n);
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}
	int cnt = 0;
	for (int ii = 0; ii < 1234567; ii++) {
		random_shuffle(a.begin(), a.end());
		random_shuffle(b.begin(), b.end());
		int win = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] > b[i]) win++;
			if (a[i] < b[i]) win--;
		}
		cnt += win > 0;
	}
	
	printf("%.20f\n", cnt / 1234567.0);
}
0