Submission #25993

#TimeUsernameProblemLanguageResultExecution timeMemory
25993H_HSenior Postmen (BOI14_postmen)C++14
55 / 100
658 ms113784 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN=500005; bool vis[MAXN]; bool vs[MAXN]; set<int>adj[MAXN]; int n,m; int cyc=-1; void dfs(int x) { vis[x]=true; while(!adj[x].empty()) { set<int>::iterator it=adj[x].end(); --it; int y=*it; adj[x].erase(it); adj[y].erase(adj[y].find(x)); if(vis[y]) { printf("%d",x); cyc=y; break; } dfs(y); if(cyc!=-1) { printf(" %d",x); if(cyc==x) { printf("\n"); cyc=-1; } else break; } } vis[x]=false; } int main() { scanf("%d%d",&n,&m); for(int i=0;i<m;i++) { int x,y; scanf("%d%d",&x,&y); adj[x].insert(y); adj[y].insert(x); } for(int i=1;i<=n;i++)dfs(i); return 0; }

Compilation message (stderr)

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