제출 #1279622

#제출 시각아이디문제언어결과실행 시간메모리
1279622DanielPr8Amusement Park (CEOI19_amusementpark)C++20
7 / 100
1 ms576 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using vll = vector<ll>; using vvl = vector<vll>; using pll = pair<ll,ll>; #define f first #define s second #define pb push_back #define all(v) v.begin(),v.end() const int mod = 998244353; int main(){ ios_base::sync_with_stdio(0);cin.tie(NULL); ll n, m; cin >> n >> m; vvl g(n); vvl cn(n, vll(n)); for(ll a,b,i = 0; i < m; ++i){ cin >> a >> b; g[--a].pb(--b); cn[a][b]=cn[b][a]=1; } vll dp(1<<n); vvl mul(1<<n, vll(n)); for(ll i = 1; i < (1<<n); ++i){ for(ll j = 0; j < n; ++j){ if(!(i & (1<<j)))continue; ll cnt=0; for(ll x:g[j])if(i&(1<<x))cnt++; ll p=0; if(__builtin_popcount(i)==1)p=1; for(ll k = 0; k < n; ++k){ if(cn[k][j] || k<j)p+=mul[i^(1<<j)][k]; } dp[i] += dp[i^(1<<j)]+cnt*p; dp[i]%=mod; mul[i][j] = p; } } cout << dp.back(); }
#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...