Submission #741114

# Submission time Handle Problem Language Result Execution time Memory
741114 2023-05-13T14:39:29 Z AverageAmogusEnjoyer Amusement Park (CEOI19_amusementpark) C++17
0 / 100
1 ms 212 KB
/*
ID: dalpone1
TASK: amusementpark
LANG: C++
*/
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end() 
#define pb push_back
#define ll long long
#define nl '\n'
const int N = 19, mod = 998244353;
int n, m;
ll dp[1 << N], compute[N];
vector<int> adj[N];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for (ll i = 1; i < N; i++) {
		compute[i] = (1 << (i-1)) * i;
	}
	for (int i = 0, s, e; i < m; i++) {
		cin >> s >> e;
		s--, e--;
		adj[s].pb(e);
		adj[e].pb(s);
	}
	int sz = 1 << n;
	for (int i = 0; i < sz; i++) {
		ll add = 0;
		for (int j = 0; j < n; j++) {
			if ((i & (1 << j)) == 0) continue;
			int count = 0;
			for (int k: adj[j])
				if ((1 << k) & i) 
					count++;
			add += compute[count];
			dp[i] = ((dp[i] % mod) + (dp[i ^ (1 << j)] % mod)) % mod;
		}
		dp[i] = ((dp[i] % mod) + (add % mod) / 2) % mod;
	}
	cout << dp[sz-1];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -