Submission #240490

#TimeUsernameProblemLanguageResultExecution timeMemory
240490karmaSenior Postmen (BOI14_postmen)C++14
55 / 100
530 ms40952 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,avx2,fma") #define pb emplace_back #define ll long long #define fi first #define se second #define mp make_pair //#define int int64_t using namespace std; const int N = int(5e5) + 10; typedef pair<int, int> pii; int n, m, vis[N], ss[N], st[N], cnts, cntt; int path[N], cp, u, v, id, del[N]; vector<pii> adj[N]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #define Task "test" if(fopen(Task".inp", "r")) { freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout); } cin >> n >> m; for(int i = 1; i <= m; ++i) { cin >> u >> v; adj[u].pb(v, i); adj[v].pb(u, i); } path[++cp] = 1; do { u = path[cp]; while(adj[u].size() && del[adj[u].back().se]) adj[u].pop_back(); if(adj[u].size()) { tie(v, id) = adj[u].back(); adj[u].pop_back(); del[id] = 1; path[++cp] = v; } else { st[++cntt] = u; --cp; } } while(cp > 0); while(cntt) { if(vis[st[cntt]]) { while(1) { vis[ss[cnts]] = 0; cout << ss[cnts] << ' '; if(ss[cnts --] == st[cntt]) break; } cout << '\n'; } vis[st[cntt]] = 1; ss[++cnts] = st[cntt]; --cntt; } }

Compilation message (stderr)

postmen.cpp: In function 'int32_t main()':
postmen.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(Task".inp", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
postmen.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(Task".out", "w", stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...