제출 #941017

#제출 시각아이디문제언어결과실행 시간메모리
941017KaleemRazaSyed어르신 집배원 (BOI14_postmen)C++17
0 / 100
6 ms12888 KiB
#include<iostream> #include<vector> using namespace std; const int N = 5e5+5; struct edge { int u, v; bool vis; int other(int x) { return u + v - x; } }; vector<int> G[N]; vector<edge> e; vector<int> p; void dfs(int v) { p.push_back(v); while(G[v].size()) { int i = G[v].back(); G[v].pop_back(); if(e[i].vis) continue; e[i].vis = true; dfs(e[i].other(v)); } } bool seen[N]; int main() { int n, m; cin >> n >> m; for(int i = 0; i < m; i ++) { int u, v; cin >> u >> v; G[u].push_back(i); G[v].push_back(i); e.push_back(edge{u, v, false}); } dfs(1); vector<int> ans; for(int i = 0; i < p.size(); i++) { if(!seen[p[i]]) ans.push_back(p[i]); else { cout << p[i]; while(ans.back() != p[i]) { cout <<' ' << ans.back(); seen[ans.back()] = false; ans.pop_back(); } cout << '\n'; } seen[p[i]] = true; } return 0; }

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

postmen.cpp: In function 'int main()':
postmen.cpp:51:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   for(int i = 0; i < p.size(); i++)
      |                  ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...