Submission #74611

#TimeUsernameProblemLanguageResultExecution timeMemory
74611tmwilliamlin168Senior Postmen (BOI14_postmen)C++14
0 / 100
24 ms12416 KiB
#include <bits/stdc++.h> using namespace std; const int mxN=5e5; int n, m, eu[mxN], ev[mxN]; vector<int> adj[mxN], a1, a2; bool a[mxN], b[mxN]; void dfs(int u) { while(adj[u].size()) { int e=adj[u].back(); adj[u].pop_back(); if(a[e]) continue; a[e]=1; a1.push_back(u); dfs(eu[e]^ev[e]^u); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i=0; i<m; ++i) { cin >> eu[i] >> ev[i], --eu[i], --ev[i]; adj[eu[i]].push_back(i); adj[ev[i]].push_back(i); } dfs(0); a1.push_back(0); // cout << "hi1" << endl; for(int i=0; i<a1.size(); ++i) { // cout << i << " " << a1[i] << endl; if(b[a1[i]]) { // cout << i << endl; while(b[a1[i]]) { // cout << a2.size() << " " << a2.back() << endl; cout << a2.back()+1 << " "; b[a2.back()]=0; a2.pop_back(); } cout << "\n"; } a2.push_back(a1[i]); b[a1[i]]=1; } }

Compilation message (stderr)

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