# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
941111 | Sir_Ahmed_Imran | Senior Postmen (BOI14_postmen) | C++17 | 583 ms | 124092 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |