Submission #779320

#TimeUsernameProblemLanguageResultExecution timeMemory
779320nononoAmusement Park (CEOI19_amusementpark)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int mod = 998244353; const int N = 18; int n, m; int slide[N][N]; int Use[N][N]; long long dp1[1 << N], dp2[1 << N]; signed main(){ #define taskname "" if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } cin.tie(0)->sync_with_stdio(0); cin >> n >> m; for(int i = 1; i <= m; i ++){ int a, b; cin >> a >> b; a -- ; b -- ; slide[a][b] = 0; slide[b][a] = 1; Use[a][b] = 1; Use[b][a] = 1; } for(int i = 0; i < n; i ++) dp1[1 << i] = 1; for(int mask = 1; mask < (1 << n); mask ++){ for(int x = (1 << n) - 1 - mask; x > 0; x ^= x & (- x)){ int i = __builtin_ctz(x & (- x)); bool check = false; for(int y = mask; y > 0; y ^= y & (- y)){ int j = __builtin_ctz(y & (- y)); check = (check || Use[j][i]); } if(check){ for(int y = mask; y > 0; y ^= y & (- y)){ int j = __builtin_ctz(y & (- y)); (dp2[mask ^ (1 << i)] += dp1[mask] * slide[j][i]) %= mod; } (dp2[mask ^ (1 << i)] += dp2[mask]) %= mod; (dp1[mask ^ (1 << i)] += dp1[mask]) %= mod; } } } cout << dp2[(1 << n) - 1] << "\n"; return 0; }

Compilation message (stderr)

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
amusementpark.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen(taskname".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...