Submission #846445

#TimeUsernameProblemLanguageResultExecution timeMemory
846445CookieSenior Postmen (BOI14_postmen)C++14
0 / 100
5 ms13172 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];
bool vis[mxn + 1], used[mxn + 1];
void dfs(int s){
    if(vis[s]){
        vt<int>res;
        int x = s;
        while(vis[x]){
            cout << x << ' '; vis[x] = 0; x = trace[x];
        }
        cout << "\n";
    }
    for(auto [v, id]: adj[s]){
        if(!used[id]){
            used[id] = 1; vis[s] = 1; trace[v] = s;
            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 |     for(auto [v, id]: adj[s]){
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...