# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
39890 | Lkvatashidze | Senior Postmen (BOI14_postmen) | C++14 | 6 ms | 384 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>
using namespace std;
int n, m;
int g[2005][2005];
vector < int > ans;
/* void DFS (int v) {
set < int > ::iterator st_it;
for (st_it=g[v].begin(); st_it!=g[v].end(); st_it++) {
int p=(*st_it);
g[v].erase(p);
g[p].erase(v);
ans.push_back(v);
DFS(p);
}
for (int k=0; k<ans.size(); k++) {
cout << ans[k] << ' ';
exit(0);
}
} */
void DFS (int v) {
for (int k=1; k<=n; k++)
if (g[k][v]>0) {
g[k][v]--;
g[v][k]--;
DFS(k);
}
ans.push_back(v);
}
int main () {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int k=1; k<=m; k++) {
int x, y;
cin >> x >> y;
// g[x].insert(y);
// g[y].insert(x);
g[x][y]++;
g[y][x]++;
}
DFS(1);
for (int k=0; k<ans.size()-1; k++)
cout << ans[k] << ' ';
return 0;
}
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... |