제출 #1119658

#제출 시각아이디문제언어결과실행 시간메모리
1119658vjudge1어르신 집배원 (BOI14_postmen)C++17
100 / 100
469 ms67688 KiB
#include<bits/stdc++.h> #define int long long #define ii pair < int , int > #define iii pair < int , ii > #define iv pair < ii , ii > #define fi first #define se second #define task "senior_postmen" using namespace std; const int N = 5e5 + 5; const int mod = 998244353; int n, m; vector< ii > g[N]; bool used_edge[N]; bool vis[N], del[N]; list<int> euler_walk(int u) { list<int> ans; ans.push_back(u); while (!g[u].empty()) { int v = g[u].back().fi; int eid = g[u].back().se; g[u].pop_back(); if (used_edge[eid]) continue; used_edge[eid] = true; u = v; ans.push_back(u); } for (auto it = ++ans.begin(); it != ans.end(); ++it) { auto t = euler_walk(*it); t.pop_back(); ans.splice(it, t); } return ans; } main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); // freopen(task".out", "w", stdout); } cin >> n >> m; for(int i = 1; i <= m; i++) { int u, v; cin >> u >> v; g[u].push_back(ii(v, i)); g[v].push_back(ii(u, i)); } list < int > ct_euler = euler_walk(1); // for(auto x : ct_euler) cout << x << " "; cout << endl; stack < int > st; for(auto x : ct_euler){ if(vis[x]){ while(!st.empty()){ int v = st.top(); cout << v << " "; vis[v] = 0; st.pop(); if(v == x) break; } cout << '\n'; } st.push(x); vis[x] = 1; } }

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

postmen.cpp:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main()
      | ^~~~
postmen.cpp: In function 'int main()':
postmen.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...