結果

問題 No.702 中央値を求めよ LIMITED
コンテスト
ユーザー merom686
提出日時 2018-06-15 22:41:09
言語 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
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 738 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 405 ms
コンパイル使用メモリ 78,116 KB
最終ジャッジ日時 2026-06-05 16:43:38
合計ジャッジ時間 1,060 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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>'; this is probably fixable by adding '#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>'; this is probably fixable by adding '#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>'; this is probably fixable by adding '#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>'; this is probably fixable by adding '#include <cstdint>'
main.cpp:30:26: error: no matching function for call to 'generate()'
   30 |         auto t = generate();
      |                  ~~~~~~~~^~
main.cpp:30:26: note: there is 1 candidate
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:63,
                 from main.cpp:4:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algo.h:4390:5: note: candidate 1: 'template<class _FIter, class _Generator> void std::generate(_FIter, _FIter, _Generator)'
 4390 |     generate(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algo.h:4390:5: note: candidate expects 3 arguments, 0 provided
main.cpp:31:13: error: 'h' was not declared in this scope
   31 |         if (h - d < t && t < h + d) a[k++] = t;

ソースコード

diff #
raw source code

#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;
}
0