Submission #941111

#TimeUsernameProblemLanguageResultExecution timeMemory
941111Sir_Ahmed_ImranSenior Postmen (BOI14_postmen)C++17
55 / 100
583 ms124092 KiB
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define ll long long #define append push_back #define add insert #define nl "\n" #define ff first #define ss second #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL) #define N 500001 int st; set<int> a[N]; vector<int> x; int vis[N]; void dfs(int v){ int u; vis[v]=1; x.append(v); while(!a[v].empty()){ u=*a[v].begin(); a[v].erase(u); a[u].erase(v); if(vis[u]){ cout<<u<<' '; while(x.back()!=u){ cout<<x.back()<<' '; vis[x.back()]=0; x.pop_back(); } cout<<nl; st=u; } else dfs(u); if(v!=st) return; } } void solve(){ int n,m,o,p,q,r; cin>>n>>m; for(int i=0;i<m;i++){ cin>>p>>q; a[p].add(q); a[q].add(p); } for(int i=1;i<=n;i++) if(!a[i].empty()) dfs(i); } int main(){ solve(); return 0; }

Compilation message (stderr)

postmen.cpp: In function 'void solve()':
postmen.cpp:41:13: warning: unused variable 'o' [-Wunused-variable]
   41 |     int n,m,o,p,q,r;
      |             ^
postmen.cpp:41:19: warning: unused variable 'r' [-Wunused-variable]
   41 |     int n,m,o,p,q,r;
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...