# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
832549 | EntityPlantt | Senior Postmen (BOI14_postmen) | C++14 | 14 ms | 23772 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 <set>
using namespace std;
set <int> graph[500000], togo;
int n, m, a, b, startNode, nowNode;
set<int>::iterator nextNode;
int main() {
scanf("%d%d", &n, &m);
while (m--) {
scanf("%d%d", &a, &b);
graph[--a].insert(--b);
graph[b].insert(a);
}
for (int i = 0; i < n; i++) togo.insert(i);
while (!togo.empty()) {
startNode = nowNode = *prev(togo.end());
do {
printf("%d ", nowNode + 1);
nextNode = prev(graph[nowNode].end());
graph[*nextNode].erase(nowNode);
graph[nowNode].erase(nextNode);
if (graph[nowNode].empty()) togo.erase(nowNode);
nowNode = *nextNode;
} while (startNode != nowNode);
if (graph[startNode].empty()) togo.erase(prev(togo.end()));
printf("\n");
}
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... |