제출 #116044

#제출 시각아이디문제언어결과실행 시간메모리
116044MAMBA어르신 집배원 (BOI14_postmen)C++17
55 / 100
586 ms70396 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i , j , k) for (int i = j; i < (int)k; i++) #define pb push_back #define mt make_tuple #define all(x) x.begin(),x.end() typedef long long ll; typedef pair<int , int> pii; typedef pair<ll, ll> pll; typedef long double ld; typedef complex<ld> point; typedef pair<ld , ld> pld; typedef vector<ll> vi; inline void fileIO(string s) { // freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } template<class T , class S> inline bool smin(T &a, S b) { return (T)b < a ? a = b , 1 : 0; } template<class T , class S> inline bool smax(T &a, S b) { return a < (T)b ? a = b , 1 : 0; } constexpr int N = 5e5 + 10; constexpr int MOD = 1e9 + 7; template<typename T> inline T mod(T &v) { return v = (v % MOD + MOD) % MOD; } template<typename S, typename T> inline S add(S &l, T r) { return mod(l += r); } int n, m, a[N], b[N]; vector<int> adj[N]; int ptr[N]; bitset<N> mark, mark2; int st[N], R; void dfs(int v) { for (int &id = ptr[v]; id < (int)adj[v].size(); id++) { int e = adj[v][id]; if (!mark[e]) { mark[e] = true; dfs(a[e] ^ b[e] ^ v); } } if (mark2[v]) { while (mark2[v]) { cout << st[R] << (st[R] == v ? '\n' : ' '); mark2[st[R]] = false; R--; } } mark2[v] = true; st[++R] = v; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; rep(i , 0 , m) { cin >> a[i] >> b[i]; adj[a[i]].pb(i); adj[b[i]].pb(i); } dfs(1); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...