# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
608844 | 1bin | Amusement Park (CEOI19_amusementpark) | C++14 | 1815 ms | 308860 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
const ll mod = 998244353;
ll n, m, a, b, e[18];
map<int, ll> dp[1 << 18];
int main(void){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i = 0; i < m; i++){
cin >> a >> b; a--; b--;
e[a] |= 1 << b;
e[b] |= 1 << a;
}
dp[0][(1 << n) - 1] = 1;
for(int a = 0; a < 1 << n; a++)
for(auto& [b, x] : dp[a]){
for(int i = 0; i < n; i++){
if(!(b & (1 << i))) continue;
int nxa = a | (1 << i);
int nxb = (b & ((1 << n) - 1 - ((1 << (i + 1)) - 1))) | (e[i] & ((1 << n) - 1 - nxa));
dp[nxa][nxb] += x; dp[nxa][nxb] %= mod;
}
}
cout << dp[(1 << n) - 1][0] * m % mod * (mod + 1) / 2 % mod;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |