제출 #1048001

#제출 시각아이디문제언어결과실행 시간메모리
1048001luanzito어르신 집배원 (BOI14_postmen)C++14
0 / 100
21 ms54868 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define fr first #define sc second #define bg begin() #define ed end() #define lf(no) no << 1 #define rg(no) lf(no) | 1 #define lsb(x) x & (-x) #define all(x) x.begin(),x.end() #define sz(x) (int) x.size() #define debug(x) cout << x << endl; using namespace std; using pii = pair<int,int>; using tii = tuple<int,int,int>; const int maxn = 5e5 + 10; int n,m,t,qtd[maxn],mark[maxn],mv[maxn]; vector<int> resp[maxn],id[maxn]; stack<int> p; pii e[maxn]; void find(int u){ if(mv[u]){ t++; int v; do{ v = p.top(); p.pop(); mv[v] = 0; resp[t].pb(v); }while(v != u); } if(!mv[u]){ mv[u] = 1; p.push(u); } while(sz(id[u])){ int ind = id[u].back(); if(mark[ind]){ id[u].pop_back(); continue; } mark[ind] = 1; int v = e[ind].fr + e[ind].sc - u; id[u].pop_back(); find(v); } } void solve(){ cin >> n >> m; for(int i = 1;i <= m;i++){ int u,v; cin >> u >> v; e[i] = {u,v}; id[u].pb(i); id[v].pb(i); } for(int i = 1;i <= n;i++){ find(i); while(!p.empty()) p.pop(); } for(int i = 1;i <= t;i++){ for(int v : resp[i]) cout << v << " "; cout << "\n"; } } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; //cin >> t; while(t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...