Submission #227651

#TimeUsernameProblemLanguageResultExecution timeMemory
227651arman_ferdousSenior Postmen (BOI14_postmen)C++17
55 / 100
545 ms61408 KiB
/* Author : arman_ferdous * Date : 28 Apr 2020 14:31:14 * TAG : Noob Problem */ #include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int,int>; const int N = 5e5+10; int n, m; int l[N], r[N]; vector<int> g[N]; int vis[N]; stack<int> st; void tour(int u) { while(!g[u].empty()) { int i = g[u].back(); g[u].pop_back(); if(vis[i]) continue; vis[i] = 1; tour(l[i] ^ r[i] ^ u); } st.push(u); } stack<int> soln; int main() { scanf("%d %d", &n, &m); for(int i = 0; i < m; i++) { scanf("%d %d", &l[i], &r[i]); g[l[i]].push_back(i); g[r[i]].push_back(i); } tour(1); for(int i = 1; i <= n; i++) vis[i] = 0; while(!st.empty()) { int u = st.top(); st.pop(); if(vis[u]) { printf("%d ", u); while(!soln.empty()) { int v = soln.top(); soln.pop(); if(v == u) break; printf("%d ", v); vis[v] = 0; } puts(""); } vis[u] = 1; soln.push(u); } return 0; }

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
postmen.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &l[i], &r[i]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...