제출 #1113220

#제출 시각아이디문제언어결과실행 시간메모리
1113220kh0i어르신 집배원 (BOI14_postmen)C++17
100 / 100
484 ms89132 KiB
#include "bits/stdc++.h" using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) #endif using ll = long long; using pii = pair<int, int>; #define F first #define S second #define sz(x) (int)((x).size()) #define all(x) (x).begin(), (x).end() mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll get_rand(ll l, ll r) { assert(l <= r); return uniform_int_distribution<ll> (l, r)(rng); } const int N = 5e5 + 3; int n, m; vector<pii> g[N]; bool vis[N]; vector<int> path; void dfs(int u){ while(!g[u].empty()){ auto [v, id] = g[u].back(); g[u].pop_back(); if(vis[id]) continue; vis[id] = 1; dfs(v); } path.push_back(u); } void solve(){ cin >> n >> m; for(int i = 1; i <= m; ++i){ int u, v; cin >> u >> v; g[u].emplace_back(v, i); g[v].emplace_back(u, i); } dfs(1); debug(path); set<int> st; vector<int> cur; for(int i = 0; i < sz(path) - 1; ++i){ int u = path[i]; if(st.count(u)){ cout << u; while(cur.back() != u){ st.erase(cur.back()); cout << " " << cur.back(); cur.pop_back(); } cout << '\n'; } else{ st.insert(u); cur.push_back(u); } } for(int u : cur) cout << u << " "; } int32_t main() { cin.tie(nullptr)->sync_with_stdio(0); #define task "troll" if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int test = 1; // cin >> test; for(int i = 1; i <= test; ++i){ // cout << "Case #" << i << ": "; solve(); } #ifdef LOCAL cerr << "\n[Time]: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n"; #endif return 0; }

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

postmen.cpp: In function 'int32_t main()':
postmen.cpp:79:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
postmen.cpp:80:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...