제출 #399015

#제출 시각아이디문제언어결과실행 시간메모리
399015lyc어르신 집배원 (BOI14_postmen)C++14
0 / 100
8 ms12060 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 used[mxM]; vector<int> cyc; void dfs(int u, int r) { cyc.push_back(u); for (ii& e : al[u]) if (!used[e.second]) { used[e.second] = 1; if (e.first != r) dfs(e.first, r); 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){ cyc.clear(); dfs(i,i); if (SZ(cyc) > 1) { for (int& v : cyc) { cout << v << ' '; } cout << '\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...