제출 #399017

#제출 시각아이디문제언어결과실행 시간메모리
399017lyc어르신 집배원 (BOI14_postmen)C++14
38 / 100
850 ms25404 KiB
#include <bits/stdc++.h> using namespace std; #define TRACE(x) cerr << #x << " :: " << x << endl #define _ << " " << #define SZ(x) (int)(x).size() #define ALL(x) (x).begin(),(x).end() #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define RFOR(i,a,b) for (int i=(a);i>=(b);--i) typedef pair<int,int> ii; const int mxN = 5e5+5; const int mxM = 5e5+5; int N, M; vector<ii> al[mxN]; bool vis[mxN]; bool used[mxM]; vector<int> cyc; void dfs(int u) { if (vis[u]) { int v; do { v = cyc.back(); cout << v << ' '; cyc.pop_back(); vis[v] = 0; } while (v != u); cout << '\n'; } cyc.push_back(u); vis[u] = 1; for (ii& e : al[u]) if (!used[e.second]) { used[e.second] = 1; dfs(e.first); return; } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N >> M; FOR(i,1,M){ int U, V; cin >> U >> V; al[U].push_back(ii(V,i)); al[V].push_back(ii(U,i)); } FOR(i,1,N){ dfs(i); while (SZ(cyc)) { vis[cyc.back()] = 0; cyc.pop_back(); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...