Submission #1075041

#TimeUsernameProblemLanguageResultExecution timeMemory
1075041XJP12Senior Postmen (BOI14_postmen)C++17
38 / 100
1051 ms18000 KiB
#include <iostream> #include <vector> #include<bitset> using namespace std; typedef vector<int> vi; typedef pair<int,int> ii; typedef vector<ii> vii; typedef vector<vii> vvi; bitset<1000000> mp; vvi g; vi path; vi vis; void dfs(int u){ path.push_back(u); if(vis[u]==true){ int x = u; int size=(int)path.size()-1; do{ cout<<path[size]<<" "; vis[path[size]]=false; path.pop_back(); size--; }while(path[size]!=x && size>0); cout<<'\n'; } vis[u]=true; for(auto v: g[u]){ vis[u]=true; if(mp[v.second]!=1){ mp[v.second]=1; dfs(v.first); } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,m; cin>>n>>m; g.resize(n+1,vii()); 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[i] = 0; g[a].push_back({b,i}); g[b].push_back({a,i}); } dfs(1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...