-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shuffle.cpp
58 lines (51 loc) · 1.16 KB
/
Shuffle.cpp
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
#include <bits/stdc++.h>
using namespace std;
int main() {
for(int n=3; n<=8; n++) {
map<string,int, greater <int> >mp;
mp.clear();
mt19937 rng;
rng.seed(std::random_device()());
uniform_int_distribution<std::mt19937::result_type> dist6(0,n-1);
for(int k=1; k<1000000; k++) {
int B[n+1];
for(int r=0; r<n; r++)
B[r] = r+1;
for(int i=0;i<n;i++) {
int j = rand()%n;
swap(B[i],B[j]);
}
string str = "";
for(int i=0;i<n;i++) {
str+=to_string(B[i]);
}
mp[str]++;
}
string keymin, keymax;
int max = INT_MIN, min = INT_MAX;
int cnt = 0;
for (auto it=mp.rbegin(); it!=mp.rend() ; it++) {
if(cnt<=3) {
cout << "(" << (*it).first << ", "
<< (*it).second << ")" << endl;
}
cnt++;
if (cnt>3) break;
}
// for(auto it : mp) {
// if(it.second>max) {
// max = it.second;
// keymax = it.first;
// }
// if(it.second<min) {
// min = it.second;
// keymin = it.first;
// }
// //if(n==7)
// //cout << it.first <<" " <<it.second << endl;
// }
//cout <<keymax<<" "<<max<<endl;
//cout <<keymin<<" "<<min<<endl;
}
return 0;
}