제출 #1279616

#제출 시각아이디문제언어결과실행 시간메모리
1279616DanielPr8Amusement Park (CEOI19_amusementpark)C++20
0 / 100
1 ms572 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); for(ll a,b,i = 0; i < m; ++i){ cin >> a >> b; g[--a].pb(--b); } vll dp(1<<n); vll fac(n+1, 1); for(ll i = 1; i <= n; ++i)fac[i]=(fac[i-1]*i)%mod; for(ll i = 1; i < (1<<n); ++i){ ll mul = fac[__builtin_popcount(i)-1]; for(ll j = 0; j < n; ++j){ if(!(i & (1<<j)))continue; dp[i] += dp[i^(1<<j)]; dp[i] %= mod; for(ll x:g[j]){ if(i&(1<<x))dp[i]+=mul; } dp[i]%=mod; } } 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...