-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext_permutation.cpp
More file actions
50 lines (41 loc) · 1.09 KB
/
Copy pathnext_permutation.cpp
File metadata and controls
50 lines (41 loc) · 1.09 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
#include <bits/stdc++.h>
#define endl "\n"
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef tuple<int,int,int> tp;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef unordered_map<int, int> mpii;
int main() {
vector<vector<int>> dice;
int answer = 1;
for(;;answer++) {
string s = to_string(answer);
vi v(dice.size());
iota(all(v),0);
bool pass = false;
do {
bool chk = true;
for(int i=0; i<s.size(); i++){
if(find(all(dice[v[i]]), s[i] - '0') == dice[v[i]].end()){
chk = false;
break;
}
}
if(chk){
pass = true;
break;
}
} while(next_permutation(all(v)));
if(!pass){
cout << answer;
break;
}
}
} // {{0, 1, 5, 3, 9, 2}, {2, 1, 0, 4, 8, 7}, {6, 3, 4, 7, 6, 5}}