Submission #208734

#TimeUsernameProblemLanguageResultExecution timeMemory
208734E869120Senior Postmen (BOI14_postmen)C++14
55 / 100
554 ms41436 KiB
#include <iostream> #include <vector> #include <set> using namespace std; struct Node { int to, cap, rev; }; int N, M, A[500009], B[500009]; vector<Node> X[500009]; int cur[500009]; bool used[500009]; int vec[500009], sz; int v1[500009], sz1; int main() { scanf("%d%d", &N, &M); for (int i = 1; i <= M; i++) { scanf("%d%d", &A[i], &B[i]); X[A[i]].push_back(Node{ B[i], 1, (int)X[B[i]].size() }); X[B[i]].push_back(Node{ A[i], 1, (int)X[A[i]].size() - 1 }); } int num = M, cnt = 1; while (num > 0) { while (true) { while (cur[cnt] < X[cnt].size() && X[cnt][cur[cnt]].cap == 0) cur[cnt]++; if (cur[cnt] < X[cnt].size()) break; cnt++; } int cx = cnt; sz = 0; while (true) { vec[sz] = cx; sz++; int nex = -1, res = -1; while (X[cx][cur[cx]].cap == 0) cur[cx]++; nex = X[cx][cur[cx]].to; res = X[cx][cur[cx]].rev; X[cx][cur[cx]].cap = 0; X[nex][res].cap = 0; num--; if (nex == cnt) break; cx = nex; } vec[sz] = cnt; sz++; for (int i = 0; i < sz; i++) used[vec[i]] = false; sz1 = 0; for (int i = 0; i < sz; i++) { if (used[vec[i]] == true) { int num = 0; while (true) { int cp = v1[sz1 - 1]; if (num) printf(" "); printf("%d", cp); num++; used[cp] = false; sz1--; if (cp == vec[i]) break; } printf("\n"); } used[vec[i]] = true; v1[sz1] = vec[i]; sz1++; } } return 0; }

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:28:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while (cur[cnt] < X[cnt].size() && X[cnt][cur[cnt]].cap == 0) cur[cnt]++;
           ~~~~~~~~~^~~~~~~~~~~~~~~
postmen.cpp:29:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (cur[cnt] < X[cnt].size()) break;
        ~~~~~~~~~^~~~~~~~~~~~~~~
postmen.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
postmen.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &A[i], &B[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...