제출 #547282

#제출 시각아이디문제언어결과실행 시간메모리
547282Jomnoi어르신 집배원 (BOI14_postmen)C++17
100 / 100
427 ms66236 KiB
#include <bits/stdc++.h> #define DEBUG 0 using namespace std; const int MAX_N = 5e5 + 10; vector <pair <int, int>> graph[MAX_N]; vector <int> order; bool used[MAX_N], visited[MAX_N]; void dfs(int u) { while(!graph[u].empty()) { auto [v, i] = graph[u].back(); graph[u].pop_back(); if(used[i] == false) { used[i] = true; dfs(v); } } order.push_back(u); } int main() { cin.tie(0)->sync_with_stdio(0); int n, m; cin >> n >> m; for(int i = 1; i <= m; i++) { int u, v; cin >> u >> v; graph[u].emplace_back(v, i); graph[v].emplace_back(u, i); } dfs(1); stack <int> ans; for(int i = 0; i < order.size(); i++) { if(visited[order[i]] == true) { cout << order[i] << ' '; while(ans.top() != order[i]) { visited[ans.top()] = false; cout << ans.top() << ' '; ans.pop(); } cout << '\n'; } else { visited[order[i]] = true; ans.push(order[i]); } } return 0; }

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

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