-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstead1.cpp
95 lines (86 loc) · 1.57 KB
/
stead1.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
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
85
86
87
88
89
90
91
92
93
94
95
#include <iostream>
#include <map>
#include <vector>
#include <set>
#define pr pair <int, set <int> >
using namespace std;
void printarr(int arr[], int b){
for(int i=0; i<b; i++)
cout<<arr[i]<<" ";
cout<<endl;
}
void swap(int &a, int &b){
int t = a;
a = b;
b = t;
}
void permute(int start, int cows, int arr[]){
if(start < cows-1){
for(int i=start; i<cows; i++){
swap(arr[i], arr[start]);
permute(start+1, cows, arr);
swap(arr[i], arr[start]);
}
return;
}
else{
printarr(arr, cows);
return;
}
}
int main()
{
set <pr> mp;
int arr[4] = {1,2,3, 4};
permute(0, 4, arr);
cout<<endl;/*
set <int> p(arr, arr+4);
p.insert(2);
p.insert(2);
set <int> :: iterator it = p.begin();
for(; it!=p.end();it++)
cout<<*it<<" ";
cout<<endl;
if(p.count(1) > 0)
cout<<"hello"<<endl;*/
/*for
int arr[4] = {1,1,3,2};
vector <int> v(arr, arr+4), v1(arr,arr+4);
cout<<mp.count(v)<<endl;
mp[v]=1;
cout<<mp.count(v)<<endl;
v[1]++;
cout<<mp.count(v)<<endl;
v[1]--;
cout<<mp.count(v1)<<endl;*/
/*
int arr[6] = {0, 4, 3, 2, 1, 2};
int assgn[4] = {2, 2, 1, 3};
int pref[][4] = { {1, 2, 3, 4},
{1, 3, 2, 4},
{2, 1, 3, 4},
{3, 2, 4, 1},
{4, 1, 2, 3},
{2, 4, 1, 2} };
int k=0, min = pref[arr[0]][0], max=min;
int m;
bool b = true;
for(int i=0; i<6; i++){
if(b)
m = assgn[k];
cout<<"Cow"<<arr[i]<<"Barn"<<k<<" ";
if(m > 0){
if (pref[arr[i]][k] < min)
min = pref[arr[i]][k];
if(pref[arr[i]][k] > max)
max = pref[arr[i]][k];
m--;
}
b = false;
if(m==0){
k++;
b=true;
}
}*/
return 0;
}