This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 5e5+3;
int i,j,p,q,n,m,k;
int used[maxn],uk[maxn],came[maxn],usedge[maxn];
vector <pair <int,int>> v[maxn];
vector <vector <int>> ans;
void dfs(int u)
{
if(used[u]){
p = u;
while(used[p])
{
cout<<p<<" ";
used[p] = 0;
p = came[p];
}
cout<<endl;
}
while(uk[u]<v[u].size())
{
q = v[u][uk[u]].second;
int edge = v[u][uk[u]].first;
uk[u]++;
if(!usedge[edge])
{
usedge[edge] = true;
used[u] = 1;
came[q] = u;
dfs(q);
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>m;
for(i=1;i<=m;i++)
{
cin>>p>>q;
v[p].push_back({i,q});
v[q].push_back({i,p});
}
dfs(1);
return 0;
}
Compilation message (stderr)
postmen.cpp: In function 'void dfs(int)':
postmen.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | while(uk[u]<v[u].size())
| ~~~~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |