結果
| 問題 |
No.702 中央値を求めよ LIMITED
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-16 16:22:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 929 bytes |
| コンパイル時間 | 893 ms |
| コンパイル使用メモリ | 85,068 KB |
| 最終ジャッジ日時 | 2025-01-02 01:28:06 |
| 合計ジャッジ時間 | 1,664 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:15:13: error: ‘uint32_t’ does not name a type
15 | using u32 = uint32_t;
| ^~~~~~~~
main.cpp:12:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
11 | #include <cmath>
+++ |+#include <cstdint>
12 |
main.cpp:20:1: error: ‘u32’ does not name a type
20 | u32 x = 0, y = 1, z = 2, w = 3;
| ^~~
main.cpp:21:1: error: ‘u32’ does not name a type
21 | u32 generate() {
| ^~~
main.cpp: In function ‘int main()’:
main.cpp:31:5: error: ‘u32’ was not declared in this scope
31 | u32 ng = 2140000000, ok = 2155000000;
| ^~~
main.cpp:32:8: error: expected ‘;’ before ‘seed’
32 | u32 seed; cin >> seed;
| ^~~~~
| ;
main.cpp:32:22: error: ‘seed’ was not declared in this scope
32 | u32 seed; cin >> seed;
| ^~~~
main.cpp:33:11: error: ‘ok’ was not declared in this scope
33 | while(ok-ng > 1){
| ^~
main.cpp:33:14: error: ‘ng’ was not declared in this scope
33 | while(ok-ng > 1){
| ^~
main.cpp:35:9: error: ‘uint32_t’ was not declared in this scope
35 | uint32_t cnt = 0;
| ^~~~~~~~
main.cpp:35:9: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
main.cpp:36:9: error: ‘x’ was not declared in this scope
36 | x = seed, y = 1, z = 2, w = 3;
| ^
main.cpp:36:19: error: ‘y’ was not declared in this scope; did you mean ‘yn’?
36 | x = seed, y = 1, z = 2, w = 3;
| ^
| yn
main.cpp:36:26: error: ‘z’ was not declared in this scope
36 | x = seed, y = 1, z = 2, w = 3;
| ^
main.cpp:36:33: error: ‘w’ was not declared in this scope
36 | x = seed, y = 1, z = 2, w = 3;
|
ソースコード
#include <limits>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;
template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
u32 x = 0, y = 1, z = 2, w = 3;
u32 generate() {
u32 t = (x^(x<<11));
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
return w;
}
int main() {
u32 ng = 2140000000, ok = 2155000000;
u32 seed; cin >> seed;
while(ok-ng > 1){
auto mid = ng + ((ok-ng)>>1);
uint32_t cnt = 0;
x = seed, y = 1, z = 2, w = 3;
for (int i = 0; i < 10000001; ++i) {
if(generate() <= mid) cnt++;
}
(cnt >= 5000001 ? ok : ng) = mid;
}
cout << ok << "\n";
return 0;
}