제출 #396087

#제출 시각아이디문제언어결과실행 시간메모리
396087Nicholas_Patrick어르신 집배원 (BOI14_postmen)C++17
55 / 100
671 ms80196 KiB
#include <cstdio> #include <queue> #include <unordered_set> using namespace std; int main(){ int n, m; scanf("%d%d", &n, &m); vector<unordered_set<int>> adjLis(n); for(int i=m; i--;){ int a, b; scanf("%d%d", &a, &b), a--, b--; adjLis[a].insert(b); adjLis[b].insert(a); } vector<bool> visited(n, false); for(int i=n; i--;){ int x=i; vector<int> ans; while(not adjLis[i].empty()){ ans.push_back(x); visited[x]=true; auto it=adjLis[x].begin(); if(it==adjLis[x].end()){ printf("X_X\n"); return 0; } int y=*it; adjLis[x].erase(it); adjLis[y].erase(x); if(visited[y]){ while(ans.back()!=y){ printf("%d ", ans.back()+1); visited[ans.back()]=false; ans.pop_back(); } printf("%d\n", ans.back()+1); visited[ans.back()]=false; ans.pop_back(); x=y; }else{ x=y; } } } }

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

postmen.cpp: In function 'int main()':
postmen.cpp:8:7: 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:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |   scanf("%d%d", &a, &b), a--, b--;
      |   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...