結果
| 問題 | No.702 中央値を求めよ LIMITED |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-07 23:40:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1,760 ms / 5,000 ms |
| コード長 | 1,220 bytes |
| 記録 | |
| コンパイル時間 | 633 ms |
| コンパイル使用メモリ | 78,664 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-25 05:53:09 |
| 合計ジャッジ時間 | 49,089 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
extern int Measure(int RM, int CM);
extern void Pinpoint(int RP, int CP);
#include <cstdio>
#include <vector>
#include <cassert>
#include <iostream>
#include <cstdint>
#include <chrono>
#include <algorithm>
#include <map>
using namespace std;
#define I64 int64_t
#define curtime chrono::system_clock::time_point
#define getcurtime chrono::system_clock::now
uint32_t x = 0, y = 1, z = 2, w = 3;
int64_t g_seed;
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 check(uint32_t a, bool& same){
same = false;
uint32_t q;
int ret = 0;
x = g_seed;
y = 1;
z = 2;
w = 3;
for (int i = 0; i < 10000001; i++){
q = generate();
if(q < a){
ret++;
} else if(q == a){ same = true; }
}
return ret;
}
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
bool same = false;
std::cin >> g_seed;
uint32_t min, max;
min = 0; max = 4294967295;
while(min + 1 < max){
uint32_t mid = (uint32_t)((((uint64_t)min + (uint64_t)max) / (uint64_t)2));
int lownum = check(mid, same);
if(lownum <= 5000000){
min = mid;
} else {
max = mid;
}
}
cout << min << endl;
}