結果
問題 | No.702 中央値を求めよ LIMITED |
ユーザー |
![]() |
提出日時 | 2018-06-15 22:45:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,724 bytes |
コンパイル時間 | 765 ms |
コンパイル使用メモリ | 91,400 KB |
最終ジャッジ日時 | 2025-01-01 23:24:29 |
合計ジャッジ時間 | 1,161 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:48:1: error: ‘uint32_t’ does not name a type 48 | uint32_t x = 0, y = 1, z = 2, w = 3; | ^~~~~~~~ main.cpp:27:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’? 26 | #include <functional> +++ |+#include <cstdint> 27 | using namespace std; main.cpp:49:1: error: ‘uint32_t’ does not name a type 49 | uint32_t generate() { | ^~~~~~~~ main.cpp:49:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’? main.cpp: In function ‘void reset()’: main.cpp:59:5: error: ‘x’ was not declared in this scope; did you mean ‘dx’? 59 | x = seed, y = 1, z = 2, w = 3; | ^ | dx main.cpp:59:15: error: ‘y’ was not declared in this scope; did you mean ‘yn’? 59 | x = seed, y = 1, z = 2, w = 3; | ^ | yn main.cpp:59:22: error: ‘z’ was not declared in this scope 59 | x = seed, y = 1, z = 2, w = 3; | ^ main.cpp:59:29: error: ‘w’ was not declared in this scope 59 | x = seed, y = 1, z = 2, w = 3; | ^ main.cpp: In function ‘int main()’: main.cpp:73:31: error: no matching function for call to ‘generate()’ 73 | int val = generate(); | ~~~~~~~~^~ In file included from /usr/include/c++/13/algorithm:61, from main.cpp:14: /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:73:31: note: candidate expects 3 arguments, 0 provided 73 | int val = generate(); | ~~~~~~~~^~
ソースコード
// 基本テンプレート #include <iostream> #include <iomanip> #include <cstdio> #include <string> #include <cstring> #include <deque> #include <list> #include <queue> #include <stack> #include <vector> #include <utility> #include <algorithm> #include <map> #include <set> #include <complex> #include <cmath> #include <limits> #include <cfloat> #include <climits> #include <ctime> #include <cassert> #include <numeric> #include <fstream> #include <functional> using namespace std; #define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++) #define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++) #define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--) #define debug(...) fprintf(stderr, __VA_ARGS__) #define int long long int template<typename T> void chmax(T &a, T b) {a = max(a, b);} template<typename T> void chmin(T &a, T b) {a = min(a, b);} template<typename T> void chadd(T &a, T b) {a = a + b;} typedef pair<int, int> pii; typedef long long ll; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; const ll INF = 1001001001001001LL; const ll MOD = 1000000007LL; ll seed; 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; } void reset() { x = seed, y = 1, z = 2, w = 3; } const int N = 10000001; signed main() { cin >> seed; int ub = 1LL << 40, lb = -1; while(ub - lb > 1) { int mid = (ub + lb) / 2; reset(); int cnt = 0; for(int i=0; i<N; i++) { int val = generate(); if(val <= mid) cnt++; } if(cnt < N / 2 + 1) lb = mid; else ub = mid; } cout << ub << endl; return 0; }