Submission #846449

#TimeUsernameProblemLanguageResultExecution timeMemory
846449CookieSenior Postmen (BOI14_postmen)C++14
100 / 100
357 ms81908 KiB
#include<bits/stdc++.h> #define ll long long #define vt vector #define pb push_back #define pii pair<int, int> #define sz(v) (int)v.size() #define fi first #define se second using namespace std; const ll base = 107, mod = 1e9 + 7; const int mxn = 5e5 + 5; int n, m; vt<pii>adj[mxn + 1]; int trace[mxn + 1], at[mxn + 1]; bool vis[mxn + 1], used[mxn + 1]; void dfs(int s){ if(vis[s]){ int x = s; while(vis[x]){ cout << x << ' '; vis[x] = 0; x = trace[x]; } cout << "\n"; } for(int &i = at[s]; i < sz(adj[s]); i++){ auto [v, id] = adj[s][i]; if(!used[id]){ used[id] = 1; vis[s] = 1; trace[s] = v; dfs(v); } } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 0; i < m; i++){ int u, v; cin >> u >> v; adj[u].pb({v, i}); adj[v].pb({u, i}); } dfs(1); }

Compilation message (stderr)

postmen.cpp: In function 'void dfs(int)':
postmen.cpp:25:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   25 |         auto [v, id] = adj[s][i];
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...