제출 #208729

#제출 시각아이디문제언어결과실행 시간메모리
208729E869120어르신 집배원 (BOI14_postmen)C++14
55 / 100
528 ms44132 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) { vector<int> ret; while (true) { int cp = v1[sz1 - 1]; ret.push_back(cp); used[cp] = false; sz1--; if (cp == vec[i]) break; } for (int j = 0; j < ret.size(); j++) { if (j) printf(" "); printf("%d", ret[j]); } printf("\n"); } used[vec[i]] = true; v1[sz1] = vec[i]; sz1++; } } return 0; }

컴파일 시 표준 에러 (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:60:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int j = 0; j < ret.size(); j++) { if (j) printf(" "); printf("%d", ret[j]); }
                     ~~^~~~~~~~~~~~
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...