#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
int main()
{
int n,m; cin>>n>>m;
vector<vector<bool>> g(n,vector<bool>(n,false));
for (int i = 0; i < m; ++i) {
int x,y; cin>>x>>y; x--; y--;
g[x][y]= true;
g[y][x] = true;
}
int t = 1<<n;
vector<int> dp(t,0);
for (int i = 1; i < t; ++i) {
bitset<18> s = i;
if(s.count()==1) dp[i]=1;
else {
for (int k = 0; k < n; ++k) {
if(!s[k]) continue;
dp[i]+=dp[i-(1<<k)];
for (int j = 0; j < k; ++j) {
if(!s[j]) continue;
if(g[k][j]) continue;
dp[i]-=dp[i-(1<<k)-(1<<j)];
}
}
}
}
cout<<dp[t-1]/2*m<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |