結果
| 問題 |
No.702 中央値を求めよ LIMITED
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2022-11-22 15:23:56 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 875 bytes |
| コンパイル時間 | 1,217 ms |
| コンパイル使用メモリ | 124,116 KB |
| 最終ジャッジ日時 | 2025-01-02 00:13:07 |
| 合計ジャッジ時間 | 1,649 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:16:1: error: unknown type name 'uint32_t'
16 | uint32_t x = 0, y = 1, z = 2, w = 3;
| ^
main.cpp:16:18: error: expected ';' after top level declarator
16 | uint32_t x = 0, y = 1, z = 2, w = 3;
| ^
| ;
main.cpp:17:1: error: unknown type name 'uint32_t'
17 | uint32_t generate() {
| ^
main.cpp:18:3: error: unknown type name 'uint32_t'
18 | uint32_t t = (x^(x<<11));
| ^
main.cpp:19:7: error: use of undeclared identifier 'y'
19 | x = y;
| ^
main.cpp:20:3: error: use of undeclared identifier 'y'
20 | y = z;
| ^
main.cpp:20:7: error: use of undeclared identifier 'z'
20 | y = z;
| ^
main.cpp:21:3: error: use of undeclared identifier 'z'
21 | z = w;
| ^
main.cpp:21:7: error: use of undeclared identifier 'w'
21 | z = w;
| ^
main.cpp:22:3: error: use of undeclared identifier 'w'
22 | w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
| ^
main.cpp:22:8: error: use of undeclared identifier 'w'
22 | w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
| ^
main.cpp:22:13: error: use of undeclared identifier 'w'
22 | w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
| ^
main.cpp:23:10: error: use of undeclared identifier 'w'
23 | return w;
| ^
main.cpp:27:3: error: unknown type name 'uint32_t'
27 | uint32_t seed;
| ^
main.cpp:38:5: error: use of undeclared identifier 'y'
38 | y = 1;
| ^
main.cpp:39:5: error: use of undeclared identifier 'z'
39 | z = 2;
| ^
main.cpp:40:5: error: use of undeclared identifier 'w'
40 | w = 3;
| ^
main.cpp:43:14: error: no matching function for call to 'generate'
43 | ll v = generate();
| ^~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algo.h:4434:5: note: candidate function template not viable: requires 3 arguments, but 0 were provi
ソースコード
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
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() {
uint32_t seed;
cin >> seed;
ll ok = 0;
ll ng = UINT_MAX;
ll a = 10000001;
while (abs(ng - ok) >= 2) {
ll mid = (ok + ng) / 2;
ll m_cnt = 0;
x = seed;
y = 1;
z = 2;
w = 3;
for (int i = 0; i < a; ++i) {
ll v = generate();
if (v <= mid) {
++m_cnt;
}
}
if (m_cnt <= a / 2) {
ok = mid;
} else {
ng = mid;
}
}
cout << ok + 1 << endl;
return 0;
}
siman