forked from yosupo06/library-checker-problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmax_random.cpp
More file actions
84 lines (77 loc) · 1.97 KB
/
max_random.cpp
File metadata and controls
84 lines (77 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "random.h"
#include "../params.h"
#include <cstdio>
#include <vector>
using namespace std;
void out(vector<int> T, Random &gen) {
int Q = T.size();
printf("%d\n", Q);
int n = 0;
for (int t : T) {
if (t == 0 || t == 1) {
int x = gen.uniform<int>(MIN_X, MAX_X);
printf("%d %d\n", t, x);
++n;
} else if (t == 2 || t == 3) {
printf("%d\n", t);
--n;
} else if (t == 4) {
int i = gen.uniform<int>(0, n - 1);
printf("%d %d\n", t, i);
} else {
assert(false);
}
}
}
int main(int, char *argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);
int Q = MAX_Q;
int prob[5];
if (seed <= 2) {
prob[0] = prob[1] = prob[2] = prob[3] = prob[4] = 20;
} else if (seed == 3) {
prob[0] = 96;
prob[1] = prob[2] = prob[3] = prob[4] = 1;
} else if (seed == 4) {
prob[1] = 96;
prob[0] = prob[2] = prob[3] = prob[4] = 1;
} else if (seed == 5) {
prob[2] = 96;
prob[0] = prob[1] = prob[3] = prob[4] = 1;
} else if (seed == 6) {
prob[3] = 96;
prob[0] = prob[1] = prob[2] = prob[4] = 1;
} else if (seed == 7) {
prob[4] = 96;
prob[0] = prob[1] = prob[2] = prob[3] = 1;
} else if (seed == 8) {
prob[0] = prob[1] = prob[4] = 32;
prob[2] = prob[3] = 2;
} else {
while (1) {
prob[0] = gen.uniform<int>(0, 100);
prob[1] = gen.uniform<int>(0, 100);
prob[2] = gen.uniform<int>(0, 100);
prob[3] = gen.uniform<int>(0, 100);
prob[4] = gen.uniform<int>(0, 100);
if (prob[0] + prob[1] + prob[2] + prob[3] + prob[4] > 0) break;
}
}
vector<int> S;
for (int k = 0; k < 5; ++k) {
for (int i = 0; i < prob[k]; ++i) S.push_back(k);
}
vector<int> T(Q);
int n = 0;
for (int q = 0; q < Q; ++q) {
int idx = gen.uniform<int>(0, int(S.size()) - 1);
int t = S[idx];
if (n == 0) t = gen.uniform<int>(0, 1);
T[q] = t;
if (t == 0 || t == 1) ++n;
if (t == 2 || t == 3) --n;
}
out(T, gen);
return 0;
}