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>
using namespace std;
#define sz(a) (int)a.size()
#define pb push_back
#define int long long
const int mxN = (int)5e5+10;
int n, m, vis[mxN], vis1[mxN], nx[mxN];
vector<pair<int,int>> v, adj[mxN];
void dfs(int s){
vis[s]=1;
while(sz(adj[s])){
auto [u,e] = adj[s].back(); adj[s].pop_back();
if(vis1[e]) continue; vis1[e]=1;
if(vis[u]==1){
int p = u;
while(vis[p]) cout<<p<<" ", vis[p]=0, p = nx[p];
cout << "\n";
}
nx[s]=u, dfs(u);
}
}
int32_t main(){
cin >> n >> m;
for(int i = 0; i < m; i++){
int a, b; cin >> a >> b;
adj[a].pb({b,i}); adj[b].pb({a,i});
}
dfs(1);
}
Compilation message (stderr)
postmen.cpp: In function 'void dfs(long long int)':
postmen.cpp:14:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
14 | if(vis1[e]) continue; vis1[e]=1;
| ^~
postmen.cpp:14:25: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
14 | if(vis1[e]) continue; vis1[e]=1;
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |