-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha.cpp
More file actions
53 lines (35 loc) · 813 Bytes
/
Copy patha.cpp
File metadata and controls
53 lines (35 loc) · 813 Bytes
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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
#define endl "\n"
#define dgb(x) cout << #x << " = " << x << "\n";
vector<int> used(10, 0);
void backtracking(vector<string>& r,string s, string o){
if (o.size() == 3){
r.push_back(o);
return;
}
for (int i=0; i < s.size(); i++){
if (used[i]) continue;
o.push_back(s[i]);
used[i] = 1;
backtracking(r, s, o);
used[i] = 0;
o.pop_back();
}
}
vector<string> permute(string s){
vector<string> r;
backtracking(r,s, "");
return r;
}
int main(){_
string a = "ABC";
for (string s: permute(a)){
cout << s << endl;
}
return 0;
}