|
爆搜
- #include <cstdio>
- const int N = 110, M = 2510;
- struct Edge {
- int v, nex;
- }edge[M << 1]; int top, e[N];
- inline void add(int x, int y) {
- top++;
- edge[top].v = y;
- edge[top].nex = e[x];
- e[x] = top;
- return;
- }
- int k, n, ans, cl[N];
- void DFS(int x) {
- if(x == n + 1) {
- ans++;
- return;
- }
- for(int i = 1; i <= k; i++) { /// color
- bool f = 1;
- for(int j = e[x]; j; j = edge[j].nex) {
- int y = edge[j].v;
- if(y > x) {
- continue;
- }
- if(cl[y] == i) {
- f = 0;
- break;
- }
- }
- if(f) {
- cl[x] = i;
- DFS(x + 1);
- }
- }
- return;
- }
- int main() {
- int m;
- scanf("%d%d%d", &n, &m, &k);
- for(int i = 1, x, y; i <= m; i++) {
- scanf("%d%d", &x, &y);
- add(x, y);
- add(y, x);
- }
- DFS(1);
- printf("%d", ans);
- return 0;
- }
复制代码 |
|