제출 #1266306

#제출 시각아이디문제언어결과실행 시간메모리
1266306PlayVoltz어르신 집배원 (BOI14_postmen)C++20
100 / 100
286 ms80920 KiB
#include <cstdio> #include <stdio.h> #include <stdbool.h> #include <iostream> #include <map> #include <vector> #include <climits> #include <stack> #include <string> #include <queue> #include <algorithm> #include <set> #include <unordered_set> #include <unordered_map> #include <cmath> #include <cctype> #include <bitset> #include <iomanip> #include <cstring> #include <numeric> #include <cassert> using namespace std; #define int long long #define pii pair<int, int> #define mp make_pair #define pb push_back #define fi first #define se second vector<int> ord; vector<bool> visited; vector<vector<pii> > graph; void dfs(int node){ while (graph[node].size()){ pii num=graph[node].back(); if (visited[num.se])graph[node].pop_back(); else{ graph[node].pop_back(); visited[num.se]=1; dfs(num.fi); } } ord.pb(node); } int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, a, b; cin>>n>>m; graph.resize(n+1); visited.resize(m, 0); for (int i=0; i<m; ++i){ cin>>a>>b; graph[a].pb(mp(b, i)); graph[b].pb(mp(a, i)); } dfs(1); vector<bool> visited(n+1, 0); vector<int> temp; for (auto node:ord){ if (visited[node]){ cout<<node<<" "; while (temp.back()!=node){ cout<<temp.back()<<" "; visited[temp.back()]=0; temp.pop_back(); } temp.pop_back(); cout<<"\n"; } temp.pb(node); visited[node]=1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...