-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path310-4.cpp
More file actions
52 lines (51 loc) · 740 Bytes
/
310-4.cpp
File metadata and controls
52 lines (51 loc) · 740 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;
const LL N = 2e5 + 10, P = 131;
int n, t, m, book[11], f[11][11], ans = 0;
vector<int>v[11];
void dfs(int i)
{
if (i > n)
{
for (int j = 1; j <= t; ++j)
if (!v[j].size())return;
++ans;
return;
}
for (int j = 1; j <= t; ++j)
{
int flag = 0;
for (auto k : v[j])
flag |= f[i][k];
if (!flag)
{
v[j].push_back(i);
dfs(i + 1);
v[j].pop_back();
}
if (!v[j].size())return;
}
}
void solve()
{
scanf("%d%d%d", &n, &t, &m);
for (int i = 1; i <= m; ++i)
{
int x, y;
scanf("%d%d", &x, &y);
f[x][y] = f[y][x] = 1;
}
dfs(1);
printf("%d\n", ans);
}
int main()
{
int T = 1;
//scanf("%d", &T);
while (T--)
{
solve();
}
return 0;
}