Submission #30938

#TimeUsernameProblemLanguageResultExecution timeMemory
30938NavickSenior Postmen (BOI14_postmen)C++14
38 / 100
1092 ms22432 KiB
#include <bits/stdc++.h> #define F first #define S second #define pii pair<int, int> #define pb push_back using namespace std; typedef long long ll; typedef long double ld; const int N = 5e5 + 10; bool mark[N], see[N]; vector<int> adj[N]; pii e[N]; vector<int> tour, st; void dfs(int v){ for(auto i : adj[v]){ if(mark[i])continue; int u = e[i].F + e[i].S - v; mark[i] = true; dfs(u); } tour.pb(v); } int main(){ int n, m; scanf("%d %d", &n ,&m); for(int i=0; i<m; i++){ int u, v; scanf("%d %d", &u, &v); adj[u].pb(i); adj[v].pb(i); e[i] = {u, v}; } dfs(1); for(auto u : tour){ if(!see[u]){ see[u] = true; st.pb(u); }else{ while(st.back() != u){ printf("%d ", st.back()); see[st.back()] = false; st.pop_back(); } printf("%d\n", u); } } }

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:30:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n, m; scanf("%d %d", &n ,&m);
            ~~~~~^~~~~~~~~~~~~~~~~
postmen.cpp:32:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int u, v; scanf("%d %d", &u, &v);
             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...