This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |