Submission #608844

#TimeUsernameProblemLanguageResultExecution timeMemory
6088441binAmusement Park (CEOI19_amusementpark)C++14
100 / 100
1815 ms308860 KiB
#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)

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:22:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   22 |         for(auto& [b, x] : dp[a]){
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...