結果
| 問題 |
No.702 中央値を求めよ LIMITED
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-10-06 20:51:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,371 bytes |
| コンパイル時間 | 817 ms |
| コンパイル使用メモリ | 91,376 KB |
| 最終ジャッジ日時 | 2025-01-01 23:02:26 |
| 合計ジャッジ時間 | 1,376 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:30:5: error: ‘uint32_t’ does not name a type
30 | uint32_t x, y, z, w;
| ^~~~~~~~
main.cpp:25:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
24 | #include <iterator>
+++ |+#include <cstdint>
25 | using namespace std;
main.cpp:32:22: error: expected ‘)’ before ‘seed’
32 | Xorshift(uint32_t seed){
| ~ ^~~~~
| )
main.cpp:38:5: error: ‘uint32_t’ does not name a type
38 | uint32_t operator()(){
| ^~~~~~~~
main.cpp:38:5: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
main.cpp: In function ‘int main()’:
main.cpp:52:27: error: no matching function for call to ‘Xorshift::Xorshift(int&)’
52 | Xorshift xorshift(seed);
| ^
main.cpp:27:7: note: candidate: ‘constexpr Xorshift::Xorshift()’
27 | class Xorshift
| ^~~~~~~~
main.cpp:27:7: note: candidate expects 0 arguments, 1 provided
main.cpp:27:7: note: candidate: ‘constexpr Xorshift::Xorshift(const Xorshift&)’
main.cpp:27:7: note: no known conversion for argument 1 from ‘int’ to ‘const Xorshift&’
main.cpp:27:7: note: candidate: ‘constexpr Xorshift::Xorshift(Xorshift&&)’
main.cpp:27:7: note: no known conversion for argument 1 from ‘int’ to ‘Xorshift&&’
main.cpp:57:31: error: no match for call to ‘(Xorshift) ()’
57 | long long a = xorshift();
| ~~~~~~~~^~
ソースコード
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
class Xorshift
{
private:
uint32_t x, y, z, w;
public:
Xorshift(uint32_t seed){
x = seed;
y = 1;
z = 2;
w = 3;
}
uint32_t operator()(){
uint32_t t=(x^(x<<11));
x=y; y=z; z=w;
return w=(w^(w>>19))^(t^(t>>8));
}
};
const unsigned MID = 0x80000000;
const int LEN = 0x300000;
int main()
{
int seed;
cin >> seed;
Xorshift xorshift(seed);
int n = 10000001;
vector<int> cnt(LEN*2+1);
for(int i=0; i<n; ++i){
long long a = xorshift();
a -= MID;
if(a < -LEN)
a = -LEN;
else if(a > LEN)
a = LEN;
++ cnt[(unsigned)a+LEN];
}
int a = 0;
int tmp = 0;
for(;;){
tmp += cnt[a];
if(tmp > n / 2)
break;
++ a;
}
long long ans = a;
ans += MID - LEN;
cout << ans << endl;
return 0;
}