# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
396086 | Nicholas_Patrick | Senior Postmen (BOI14_postmen) | C++17 | 578 ms | 82864 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 <cstdio>
#include <queue>
#include <set>
using namespace std;
int main(){
int n, m;
scanf("%d%d", &n, &m);
vector<set<int>> adjLis(n);
for(int i=m; i--;){
int a, b;
scanf("%d%d", &a, &b), a--, b--;
adjLis[a].insert(b);
adjLis[b].insert(a);
}
vector<bool> visited(n, false);
for(int i=n; i--;){
int x=i;
vector<int> ans;
while(not adjLis[i].empty()){
ans.push_back(x);
visited[x]=true;
auto it=adjLis[x].begin();
if(it==adjLis[x].end()){
printf("X_X\n");
return 0;
}
int y=*it;
adjLis[x].erase(it);
adjLis[y].erase(x);
if(visited[y]){
while(ans.back()!=y){
printf("%d ", ans.back()+1);
visited[ans.back()]=false;
ans.pop_back();
}
printf("%d\n", ans.back()+1);
visited[ans.back()]=false;
ans.pop_back();
x=y;
}else{
x=y;
}
}
}
}
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... |