답안 #741114

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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];
}
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -