Submission #88743

#TimeUsernameProblemLanguageResultExecution timeMemory
88743popovicirobertSenior Postmen (BOI14_postmen)C++14
55 / 100
525 ms51368 KiB
#include <bits/stdc++.h> #define lsb(x) (x & (-x)) #define ll long long #define ull unsigned long long // 217 // 44 using namespace std; const int MAXN = (int) 5e5; vector < pair <int, int> > g[MAXN + 1]; bool vis[MAXN + 1]; vector <int> ord; void dfs(int nod) { while(g[nod].size()) { auto it = g[nod].back(); g[nod].pop_back(); if(vis[it.second] == 0) { vis[it.second] = 1; dfs(it.first); } } ord.push_back(nod); } int main() { //ifstream cin("A.in"); //ofstream cout("A.out"); int i, n, m; ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> m; for(i = 1; i <= m; i++) { int x, y; cin >> x >> y; g[x].push_back({y, i}); g[y].push_back({x, i}); } dfs(1); memset(vis, 0, sizeof(vis)); stack <int> stk; for(i = 0; i < ord.size(); i++) { //cerr << ord[i] << "\n"; if(vis[ord[i]] == 0) { vis[ord[i]] = 1; stk.push(ord[i]); } else { while(stk.top() != ord[i]) { cout << stk.top() << " "; vis[stk.top()] = 0; stk.pop(); } cout << ord[i] << "\n"; } } //cout << ans; //cin.close(); //cout.close(); return 0; }

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:44:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i = 0; i < ord.size(); i++) {
                ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...