Submission #832549

# Submission time Handle Problem Language Result Execution time Memory
832549 2023-08-21T11:34:01 Z EntityPlantt Senior Postmen (BOI14_postmen) C++14
0 / 100
14 ms 23772 KB
#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

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 time Memory Grader output
1 Correct 12 ms 23772 KB Output is correct
2 Incorrect 12 ms 23764 KB Same junction appears twice in a route
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Incorrect 11 ms 23764 KB Same junction appears twice in a route
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23768 KB Output is correct
2 Incorrect 11 ms 23764 KB Same junction appears twice in a route
3 Halted 0 ms 0 KB -