Submission #396086

#TimeUsernameProblemLanguageResultExecution timeMemory
396086Nicholas_PatrickSenior Postmen (BOI14_postmen)C++17
55 / 100
578 ms82864 KiB
#include <cstdio> #include <queue> #include <set> using namespace std; int main(){ int n, m; scanf("%d%d", &n, &m); vector<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; } } } }

Compilation message (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...