結果
| 問題 |
No.702 中央値を求めよ LIMITED
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-12 13:51:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 862 bytes |
| コンパイル時間 | 624 ms |
| コンパイル使用メモリ | 59,064 KB |
| 最終ジャッジ日時 | 2025-01-01 22:27:16 |
| 合計ジャッジ時間 | 1,278 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:6:1: error: ‘uint32_t’ does not name a type
6 | uint32_t x = 0, y = 1, z = 2, w = 3;
| ^~~~~~~~
main.cpp:4:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
3 | #include <algorithm>
+++ |+#include <cstdint>
4 | using namespace std;
main.cpp:7:1: error: ‘uint32_t’ does not name a type
7 | uint32_t generate() {
| ^~~~~~~~
main.cpp:7:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
main.cpp:16:1: error: ‘uint32_t’ does not name a type
16 | uint32_t median = 2'147'483'648;
| ^~~~~~~~
main.cpp:16:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
main.cpp:17:1: error: ‘uint32_t’ does not name a type
17 | uint32_t width = 5'000'000;
| ^~~~~~~~
main.cpp:17:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
main.cpp:18:1: error: ‘uint32_t’ does not name a type
18 | uint32_t lower_limit = median - width;
| ^~~~~~~~
main.cpp:18:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
main.cpp:19:1: error: ‘uint32_t’ does not name a type
19 | uint32_t upper_limit = median + width;
| ^~~~~~~~
main.cpp:19:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
main.cpp: In function ‘int main()’:
main.cpp:24:5: error: ‘x’ was not declared in this scope
24 | x = seed;
| ^
main.cpp:25:12: error: ‘uint32_t’ was not declared in this scope
25 | vector<uint32_t> pool;
| ^~~~~~~~
main.cpp:25:12: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
main.cpp:25:20: error: template argument 1 is invalid
25 | vector<uint32_t> pool;
| ^
main
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
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;
}
uint32_t median = 2'147'483'648;
uint32_t width = 5'000'000;
uint32_t lower_limit = median - width;
uint32_t upper_limit = median + width;
int main(void) {
int64_t seed; cin >> seed;
x = seed;
vector<uint32_t> pool;
int count_small = 0;
uint32_t a;
for (int i = 0; i < 10000001; i++) {
a = generate();
if (a < lower_limit){
++count_small;
}else if (a <= upper_limit){
pool.push_back(a);
}
}
sort(pool.begin(), pool.end());
int n = 5'000'000 - count_small;
cout << pool[n] << endl;
return 0;
}