Submission #742059

# Submission time Handle Problem Language Result Execution time Memory
742059 2023-05-15T13:37:46 Z nishkarsh Amusement Park (CEOI19_amusementpark) C++14
0 / 100
3000 ms 212 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 18;
const int mod = 998244353;
bool isindep[1<<N];
ll dp[1<<N];
int popcnt[1<<N];
int undirected_edge[N];
int main(){
	int n,m,a,b;
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		cin >> a >> b;
		a--;b--;
		undirected_edge[a] ^= (1<<b);
		undirected_edge[b] ^= (1<<a);
	}
	for(int i = 0; i < (1<<n); i++){
		int edges = 0;
		for(int j = 0; j < n; j++){
			if(i&(1<<j)){
				popcnt[i]++;
				edges |= undirected_edge[j];
			}
		}
		if((edges&i) == 0) isindep[i] = true;
	}
	dp[0] = 1;
	for(int i = 1; i < (1<<n); i++){
		for(int j = i; j >= 0; j = (j-1)&i){
			if(isindep[j]){
				if(popcnt[j]&1) dp[i] += dp[i^j];
				else dp[i] -= dp[i^j];
			}
		}
		dp[i]%=mod;
	}
	ll ans = dp[(1<<n)-1];
	if(ans&1) ans += mod;
	ans >>= 1;
	ans *= m; ans %= mod;
	cout << ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3028 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3028 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3028 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3028 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3028 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -