제출 #374307

#제출 시각아이디문제언어결과실행 시간메모리
374307abra_stone어르신 집배원 (BOI14_postmen)C++14
55 / 100
737 ms93604 KiB
#include <iostream> #include <cstdio> #include <vector> #include <stack> #define N 500005 using namespace std; int n, m; bool v[N], vi[N]; vector<int> gr[N], gi[N], ans; stack<int> st; void f(int p) { int i; while (gr[p].size() > 0) { int ne = gr[p].back(), ni = gi[p].back(); gr[p].pop_back(); gi[p].pop_back(); if (vi[ni]) continue; vi[ni] = 1; f(ne); } ans.push_back(p); } int main() { int i, t1, t2; cin >> n >> m; for (i = 0; i < m; i++) { scanf("%d %d", &t1, &t2); gr[t1].push_back(t2); gi[t1].push_back(i); gr[t2].push_back(t1); gi[t2].push_back(i); } f(1); for (i = 0; i < ans.size(); i++) { if (v[ans[i]]) { printf("%d ", ans[i]); while (!st.empty()) { int tp = st.top(); if (tp == ans[i]) break; st.pop(); v[tp] = 0; printf("%d ", tp); } puts(""); } else { v[ans[i]] = 1; st.push(ans[i]); } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

postmen.cpp: In function 'void f(int)':
postmen.cpp:14:6: warning: unused variable 'i' [-Wunused-variable]
   14 |  int i;
      |      ^
postmen.cpp: In function 'int main()':
postmen.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for (i = 0; i < ans.size(); i++) {
      |              ~~^~~~~~~~~~~~
postmen.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |   scanf("%d %d", &t1, &t2);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...