Submission #208732

#TimeUsernameProblemLanguageResultExecution timeMemory
208732E869120Senior Postmen (BOI14_postmen)C++14
55 / 100
541 ms41952 KiB
#include <iostream> #include <vector> #include <set> using namespace std; #pragma warning (disable: 4996) struct Node { int to, cap, rev; }; int N, M, A[1 << 19], B[1 << 19]; vector<Node> X[1 << 19]; int cur[1 << 19]; bool used[1 << 19]; int vec[1 << 19], sz; int v1[1 << 19], 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:5:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning (disable: 4996)
 
postmen.cpp: In function 'int main()':
postmen.cpp:29: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:30:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (cur[cnt] < X[cnt].size()) break;
        ~~~~~~~~~^~~~~~~~~~~~~~~
postmen.cpp:19: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:21: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...