Submission #832549

#TimeUsernameProblemLanguageResultExecution timeMemory
832549EntityPlanttSenior Postmen (BOI14_postmen)C++14
0 / 100
14 ms23772 KiB
#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)

postmen.cpp: In function 'int main()':
postmen.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |         scanf("%d%d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...