結果

問題 No.702 中央値を求めよ LIMITED
コンテスト
ユーザー nmnmnmnmnmnmnm
提出日時 2018-06-15 22:43:04
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,374 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 783 ms
コンパイル使用メモリ 101,768 KB
最終ジャッジ日時 2026-05-16 20:44:21
合計ジャッジ時間 1,604 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:39:1: error: 'uint32_t' does not name a type
   39 | uint32_t x = 0, y = 1, z = 2, w = 3;
      | ^~~~~~~~
main.cpp:21:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
   20 | #include <iomanip>
  +++ |+#include <cstdint>
   21 | using namespace std;
main.cpp:40:1: error: 'uint32_t' does not name a type
   40 | uint32_t generate() {
      | ^~~~~~~~
main.cpp:40: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:52:5: error: 'x' was not declared in this scope
   52 |     x = seed;
      |     ^
main.cpp:56:24: error: no matching function for call to 'generate()'
   56 |         ll r = generate();
      |                ~~~~~~~~^~
main.cpp:56:24: 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:1:
/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 <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

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;
    ll b = 0;
    vector<ll> v;
    for (int i = 0; i < 10000001; i++) {
        ll r = generate();
        if(r<2000000000){
          b++;
        }
        else if(r>2200000000){
          // 何もしないよ
        }
        else{
          v.pb(r);
        }
    }
    sort(all(v));
    ll l = 5000000 - b;
    cout << v[l] << endl;
    return 0;
}
0