Submission #486337

#TimeUsernameProblemLanguageResultExecution timeMemory
486337XIIAmusement Park (CEOI19_amusementpark)C++17
0 / 100
0 ms204 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second #define mp make_pair #define eb emplace_back #define ALL(x) (x).begin(), (x).end() #define FOR(i, a, b) for(int i = (a); i < (b); ++i) #define FORU(i, a, b) for(int i = (a); i <= (b); ++i) #define FORD(i, a, b) for(int i = (a); i >= (b); --i) #define IOS cin.tie(0)->sync_with_stdio(false); #define PROB "CEOI19_amusementpark" void Fi(){ if(fopen(PROB".inp", "r")){ freopen(PROB".inp", "r", stdin); freopen(PROB".out", "w", stdout); } } const int N = 18; int n, m; vector<int> adj[N], radj[N]; const int MOD = 998244353; int dp[1 << N]; /// number of reverse edge int f[1 << N]; /// number of state int main(){ IOS; Fi(); cin >> n >> m; FORU(i, 1, m){ int u, v; cin >> u >> v; --u, --v; adj[u].eb(v), radj[v].eb(u); } f[0] = 1; FOR(mask, 0, 1 << n){ FOR(u, 0, n) if(!(mask & (1 << u))){ int rev = 0; for(int v: adj[u]) if(mask & (1 << v)) ++rev; (dp[mask | (1 << u)] += f[mask] * rev + dp[mask]) %= MOD; (f[mask | (1 << u)] += f[mask]) %= MOD; } } // FOR(mask, 0, 1 << n){ // cout << bitset<10>(mask) << "\n"; // cout << f[mask] << " " << dp[mask] << "\n"; // } cout << dp[(1 << n) - 1]; return 0; }

Compilation message (stderr)

amusementpark.cpp: In function 'void Fi()':
amusementpark.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen(PROB".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
amusementpark.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen(PROB".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...