Submission #1203722

#TimeUsernameProblemLanguageResultExecution timeMemory
1203722repmann어르신 집배원 (BOI14_postmen)C++20
0 / 100
145 ms327680 KiB
#include <bits/stdc++.h> using namespace std; int N, M; bitset <500001> D, V; stack <pair <int, int>> VG[500001]; inline void Euler() { int node = 1, temp; stack <int> S, T; S.push(node); while(S.size()) { node = S.top(); while(VG[node].size() && V[VG[node].top().first]) VG[node].pop(); if(VG[node].size()) { V[VG[node].top().first] = true; temp = VG[node].top().second; VG[node].pop(); S.push(temp); continue; } if(D[node]) { while(D[node]) {cout << T.top() << ' '; D[T.top()] = false; T.pop();} cout << '\n'; } T.push(node); D[node] = true; S.pop(); } return; } int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> N >> M; int u, v; for(int i = 1; i <= M; i++) { cin >> u >> v; VG[u].push({i, v}); VG[v].push({i, u}); } Euler(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...