-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathunordered_set hack.cpp
More file actions
54 lines (44 loc) · 1.14 KB
/
unordered_set hack.cpp
File metadata and controls
54 lines (44 loc) · 1.14 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
#include <bits/stdc++.h>
/*
Can be used to hack unordered_set/map solutions
in Codeforces and other similar online judges.
Implementation was taken from Codeforces.
*/
using namespace std;
const int me = 100025;
int ar[100] = {0};
unordered_set <int> S;
int main() {
srand(31);
int k, x, pos = 0, c = 0, l = 0, i = 1;
int n = 1e5; /// make n larger as possible
printf("%d\n", n);
for (i = 1; i <= n; i++) {
x = ((rand() << 15) ^ rand()) % 1000000007 + 1;
int lol = S.bucket_count();
if (lol >= 6){
c = ++ar[pos];
x = c * lol;
if (x > 1000000000){
ar[pos] = 1;
c = ar[pos];
x = c * lol;
}
while (S.count(x)) x += (rand() % 97);
}
while (S.count(x)) x += (rand() % 179371);
if (x > 1000000000){
i--;
continue;
}
//printf("%d", x);
//if(i > 1)
// putchar(' ');
S.insert(x);
k = S.bucket_count();
if (k != l) pos++;
l = k;
}
puts("");
return 0;
}