Submission #895895

#TimeUsernameProblemLanguageResultExecution timeMemory
895895magicianAmusement Park (CEOI19_amusementpark)C++14
19 / 100
2 ms604 KiB
#include<bits/stdc++.h> #define FORU(i, a, b) for(int i = (a), _b = (b); i <= _b; i++) #define MASK(x) (1 << (x)) #define BIT(x, i) (((x) >> (i)) & 1) #define TASK "AMUSEMENTPARK" #define fi first #define se second using namespace std; const int NMAX = 20, MMAX = 200; int N, M; pair<int, int> e[MMAX]; vector<int> adj[NMAX]; namespace subtask2 { bool is_sub(void) { return N <= 6; } int vis[NMAX]; bool dfs(int u, int mask) { vis[u] = 1; for(int id : adj[u]) { int v = e[id].fi + e[id].se - u; if(!BIT(mask, id - 1) && u == e[id].se) continue; if(BIT(mask, id - 1) && u == e[id].fi) continue; if(vis[v] == 1) return false; if(vis[v] == 0) if(!dfs(v, mask)) return false; } vis[u] = 2; return true; } bool chk(int mask) { FORU(i, 1, N) vis[i] = 0; FORU(i, 1, N) if(vis[i] == 0) if(!dfs(i, mask)) return false; return true; } void sol(void) { int ans = 0; FORU(mask, 0, MASK(M) - 1) { if(chk(mask)) { ans += __builtin_popcount(mask); } } cout << ans; return; } } int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); freopen(TASK".OUT", "w", stdout); } cin >> N >> M; FORU(i, 1, M) { cin >> e[i].fi >> e[i].se; adj[e[i].fi].push_back(i); adj[e[i].se].push_back(i); } if(subtask2::is_sub()) return subtask2::sol(), 0; }

Compilation message (stderr)

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