結果
問題 | No.702 中央値を求めよ LIMITED |
ユーザー |
![]() |
提出日時 | 2018-06-15 22:41:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 738 bytes |
コンパイル時間 | 622 ms |
コンパイル使用メモリ | 62,808 KB |
最終ジャッジ日時 | 2025-01-01 22:29:41 |
合計ジャッジ時間 | 1,135 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:10:1: error: ‘uint32_t’ does not name a type 10 | uint32_t a[1000000]; | ^~~~~~~~ main.cpp:8:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’? 7 | #include <cmath> +++ |+#include <cstdint> 8 | using namespace std; main.cpp:12:1: error: ‘uint32_t’ does not name a type 12 | uint32_t x = 0, y = 1, z = 2, w = 3; | ^~~~~~~~ main.cpp:12:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’? main.cpp:13:1: error: ‘uint32_t’ does not name a type 13 | uint32_t generate() { | ^~~~~~~~ main.cpp:13:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’? main.cpp: In function ‘int main()’: main.cpp:24:5: error: ‘x’ was not declared in this scope 24 | x = seed; | ^ main.cpp:26:5: error: ‘uint32_t’ was not declared in this scope 26 | uint32_t h = 1U << 31, d = 1U << 27; | ^~~~~~~~ main.cpp:26:5: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’? main.cpp:30:26: error: no matching function for call to ‘generate()’ 30 | auto t = generate(); | ~~~~~~~~^~ In file included from /usr/include/c++/13/algorithm:61, from main.cpp:4: /usr/include/c++/13/bits/stl_algo.h:4434:5: note: candidate: ‘template<class _FIter, class _Generator> void std::generate(_FIter, _FIter, _Generator)’ 4434 | generate(_ForwardIterator __first, _ForwardIterator __last, | ^~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:4434:5: note: template argument deduction/substitution failed: main.cpp:30:26: note: candidate expects 3 arguments, 0 provided 30 | auto t = generate(); | ~~~~~~~~^~ main.cpp:31:13: error: ‘h’ was not declared in this scope 31 | if (h - d < t && t < h + d) a[k++] = t;
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std; using ll = long long; uint32_t a[1000000]; uint32_t x = 0, y = 1, z = 2, w = 3; uint32_t generate() { uint32_t t = (x ^ (x << 11)); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); return w; } int main(void) { ll seed; cin >> seed; x = seed; uint32_t h = 1U << 31, d = 1U << 27; int p[2] = {}; int k = 0; for (int i = 0; i < 10000001; i++) { auto t = generate(); if (h - d < t && t < h + d) a[k++] = t; else p[t > h]++; } sort(a, a + k); cout << a[5000000 - p[0]] << endl; return 0; }