제출 #1158908

#제출 시각아이디문제언어결과실행 시간메모리
1158908paulxaxa어르신 집배원 (BOI14_postmen)C++20
38 / 100
1083 ms23752 KiB
#include <bits/stdc++.h> #define NMAX 500000 #define LOG 19 #define ll long long int #define BASE 128 #define MOD 998244353 using namespace std; ifstream fin("cod.in"); ofstream fout("cod.out"); int vis[NMAX+1]; vector<pair<int,int>> adj[NMAX+1]; bool used[NMAX+1]; vector<int> euler; void dfs(int x,int t) { for(auto [y,id] : adj[x]) { if(!used[id]) { used[id]=1; dfs(y,t); } } euler.push_back(x); } int last[NMAX+1]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int n,m; cin >> n >> m; for(int i=1;i<=m;i++) { int x,y; cin >> x >> y; adj[x].push_back({y,i}); adj[y].push_back({x,i}); } dfs(1,0); vector<int> st; for(int i : euler) { if(last[i]) { vector<int> v; v.push_back(i); while(st.back()!=i) { last[st.back()]--; v.push_back(st.back()); st.pop_back(); } st.pop_back(); last[i]--; for(int j : v) { cout << j << " "; } cout << '\n'; } st.push_back(i); last[i]++; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...