# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
846445 | Cookie | Senior Postmen (BOI14_postmen) | C++14 | 5 ms | 13172 KiB |
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];
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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |