結果

問題 No.702 中央値を求めよ LIMITED
コンテスト
ユーザー あり
提出日時 2023-02-23 11:50:56
言語 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  
(最初)
実行時間 -
コード長 827 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 610 ms
コンパイル使用メモリ 90,076 KB
最終ジャッジ日時 2026-06-05 16:56:53
合計ジャッジ時間 1,550 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:16:1: error: 'uint32_t' does not name a type
   16 | uint32_t x = 0, y = 1, z = 2, w = 3;
      | ^~~~~~~~
main.cpp:14:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
   13 | #include <bitset>
  +++ |+#include <cstdint>
   14 | using namespace std;
main.cpp:17:1: error: 'uint32_t' does not name a type
   17 | uint32_t generate() {
      | ^~~~~~~~
main.cpp:17: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:33:5: error: 'x' was not declared in this scope
   33 |     x = seed, y = 1, z = 2, w = 3;
      |     ^
main.cpp:33:15: error: 'y' was not declared in this scope
   33 |     x = seed, y = 1, z = 2, w = 3;
      |               ^
main.cpp:33:22: error: 'z' was not declared in this scope
   33 |     x = seed, y = 1, z = 2, w = 3;
      |                      ^
main.cpp:33:29: error: 'w' was not declared in this scope
   33 |     x = seed, y = 1, z = 2, w = 3;
      |                             ^
main.cpp:35:29: error: no matching function for call to 'generate()'
   35 |       long long a = generate();
      |                     ~~~~~~~~^~
main.cpp:35:29: 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:8:
/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

ソースコード

diff #
raw source code

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <queue>
#include <cassert>
#include <cmath>
#include <bitset>
using namespace std;

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() {
  int64_t seed; cin >> seed; 
  long long ok = 10000000000;
  long long ng = -1;
  while (ng + 1 < ok) {
    long long m = (ok + ng) / 2;
    int cnt = 0;
    x = seed, y = 1, z = 2, w = 3;
    for (int i = 0; i < 10000001; i++) {
      long long a = generate();
      if (a <= m) cnt++;
    }
    if (cnt <= 10000001/2) ng = m;
    else ok = m;
  }
  cout << ok << endl;
  return 0;
}
0