제출 #1074893

#제출 시각아이디문제언어결과실행 시간메모리
1074893XJP12어르신 집배원 (BOI14_postmen)C++14
0 / 100
1092 ms14192 KiB
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; map<pair<int,int>,int> mp; vvi g; vi path; vi vis; void dfs(int u){ path.push_back(u); //cout<<u<<" "<<vis[u]<<endl; if(vis[u]==true){ // cout<<"hola"<<endl; int x = u; // cout<<"a"<<endl; int size=(int)path.size()-1; // cout<<size<<endl; do{ //cout<<size<<endl; cout<<path[size]<<" "; vis[path[size]]=false; path.pop_back(); size=(int)path.size()-1; //cout<<size<<endl; }while(path[size]!=x && size>0); cout<<endl; } vis[u]=true; for(auto v: g[u]){ vis[u]=true; int a=u, b=v; if(a>b) swap(a,b); if(mp[{a,b}]!=1){ // cout<<a<<" "<<b<<endl; mp[{a,b}]=1; dfs(v); } } vis[u]=false; } int main() { int n,m; cin>>n>>m; g.resize(n+1,vi()); vis.resize(n+1,0); for(int i=0; i<m; i++){ int a,b; cin>>a>>b; if(a>b) swap(a,b); mp[{a,b}] = 0; g[a].push_back(b); g[b].push_back(a); } dfs(1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...