Submission #1127260

#TimeUsernameProblemLanguageResultExecution timeMemory
1127260TrieTrAmusement Park (CEOI19_amusementpark)C++20
19 / 100
3 ms328 KiB
#include<bits/stdc++.h> using namespace std; void local() { #define taskname "" if(fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } } #define ll long long #define fi first #define se second #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); template <class X, class Y> bool mini(X& x, Y y) {return x > y ? x = y, true : false;} template <class X, class Y> bool maxi(X& x, Y y) {return x < y ? x = y, true : false;} const int N = 18 + 5; const int mod = 998244353; void add(int& x, int y) { if((x += y) >= mod) x -= mod; } int n, m; vector<pair<int, int>> edge; namespace sub2 { bool check() { return n <= 6; } vector<int> adj[N]; int inDeg[N], res = 0; void dq(int i, int cost = 0) { if(i == m) { memset(inDeg, 0, sizeof(inDeg)); for(int u = 1; u <= n; u++) { for(int& v : adj[u]) { inDeg[v]++; } } queue<int> q; for(int u = 1; u <= n; u++) if(inDeg[u] == 0) q.emplace(u); int cnt = 0; while(!q.empty()) { int u = q.front(); q.pop(); cnt++; for(int& v : adj[u]) { inDeg[v]--; if(inDeg[v] == 0) q.emplace(v); } } if(cnt == n) add(res, cost); return; } int u, v; tie(u, v) = edge[i]; adj[u].emplace_back(v); dq(i + 1, cost); adj[u].pop_back(); adj[v].emplace_back(u); dq(i + 1, cost + 1); adj[v].pop_back(); } void solve() { dq(0); cout << res; } } int main() { fastio; local(); cin >> n >> m; for(int i = 1; i <= m; i++) { int u, v; cin >> u >> v; edge.emplace_back(u, v); } if(sub2::check()) sub2::solve(); }

Compilation message (stderr)

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