제출 #1119688

#제출 시각아이디문제언어결과실행 시간메모리
1119688vjudge1어르신 집배원 (BOI14_postmen)C++17
0 / 100
22 ms24144 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; const ll N = 1e6 + 5; ll vi[N] , n , m ,k, ok[N]; deque<int> q; vector<pair<int, int>> adj[N]; vector<int> duyet(ll u) { k++; vector<int> ans; // cout << u; ans.push_back(u); while(!adj[u].empty()) { int v = adj[u].back().first; int id = adj[u].back().second; adj[u].pop_back(); if(vi[id]) continue; vi[id] = 1; u = v; ans.push_back(u); } for (auto it = ++ans.begin(); it != ans.end(); ++it) { auto t = duyet(*it); t.pop_back(); for(auto uu : t) ans.push_back(uu); } return ans; } main() { cin >> n >> m; for(int i = 1; i <= m ; i ++) { ll x, y; cin >> x >> y; adj[x].push_back({y, i}); adj[y].push_back({x, i}); } //for(int i = 1; i <= n ; i ++) q.push_back(i); // while(!q.empty()) // { // ll u = q.front(); // if(adj[u].size() == 0) // { // q.pop_front(); // continue; // } // duyet(u); // } vector<int> p ; p = duyet(1); stack<int> st; //for(auto u : p) cout << u <<' '; //cout <<'\n'; for(auto u : p) { st.push(u); ok[u]++; if(ok[st.top()] > 1) { while(!st.empty()) { ll v = st.top(); if(ok[v] == 1 && v == u) break; ok[v]--; cout << v <<' '; st.pop(); } cout <<'\n'; } } }

컴파일 시 표준 에러 (stderr) 메시지

postmen.cpp:31:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   31 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...