-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeppetto.cpp
65 lines (55 loc) · 1.08 KB
/
Geppetto.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
#include <bits/stdc++.h>
#define input freopen("in.txt", "r", stdin)
#define output freopen("out.txt", "w", stdout)
using namespace std;
int n,pizzas;
bool ingredientes[20];
vector<int> pares[20];
bool any_par(int i){
for (int p = 0; p < pares[i].size(); p++)
{
if (ingredientes[pares[i][p]])
{
return 1;
}
}
return 0;
}
void mezcla(int ini){
for (int i = ini; i < n; i++)
{
if (i!=ini){
ingredientes[i-1]=0;
}
if (!any_par(i))
{
pizzas++;
ingredientes[i]=1;
mezcla(i+1);
}
}
}
int main(){
input;
int m;
scanf("%d %d",&n,&m);
memset(ingredientes,0,sizeof(ingredientes));
if (m==0)
{
printf("%d",int(pow(2,n)));
return 0;
}
for (int i = 0; i < m; i++)
{
int a,b;
scanf("%d %d",&a,&b);
a--;b--;
if (a>b)
pares[a].push_back(b);
else
pares[b].push_back(a);
}
mezcla(0);
printf("%d",pizzas+1);
return 0;
}