#include <bits/stdc++.h>
using namespace std;
int n;
int m;
int used[50][50];
int main()
{
ios_base::sync_with_stdio(false);
cin >> n >> m;
for(int i = 1; i <= m; i ++){
int x, y;
cin >> x >> y;
used[x][y] = 1;
used[y][x] = 1;
}
int res = 0;
for(int i = 0; i < (1 << n); i ++){
vector<int> t;
for(int j = 0; j < n; j ++){
if(i & (1 << j)) t.push_back(j + 1);
}
int good = 1;
for(int j = 0; j < (int)t.size(); j ++){
for(int k = j + 1; k < (int)t.size(); k ++){
good &= (used[t[j]][t[k]] == 0);
}
}
res += good;
}
cout << res << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
404 ms |
384 KB |
Output is correct |
4 |
Correct |
370 ms |
504 KB |
Output is correct |
5 |
Correct |
365 ms |
504 KB |
Output is correct |
6 |
Correct |
369 ms |
504 KB |
Output is correct |
7 |
Correct |
368 ms |
516 KB |
Output is correct |
8 |
Correct |
379 ms |
384 KB |
Output is correct |
9 |
Correct |
366 ms |
520 KB |
Output is correct |
10 |
Correct |
370 ms |
504 KB |
Output is correct |