Submission #499599

#TimeUsernameProblemLanguageResultExecution timeMemory
499599LoboSenior Postmen (BOI14_postmen)C++17
0 / 100
7 ms13260 KiB
#include<bits/stdc++.h> using namespace std; /*for ordered_set #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> */ const long long INFll = (long long) 1e18 + 10; const int INFii = (int) 1e9 + 10; typedef long long ll; typedef int ii; typedef long double dbl; #define endl '\n' #define sc second #define fr first #define mp make_pair #define pb push_back #define all(x) x.begin(), x.end() #define maxn 550000 ii n, m, blk[maxn], lt[maxn], nx[maxn], mark[maxn]; vector<pair<ii,ii>> g[maxn], vlr; vector<ii> vec; void dfs(ii u) { vec.pb(u); while(g[u].size()) { ii v = g[u].back().fr; ii id = g[u].back().sc; g[u].pop_back(); if(blk[id]) continue; blk[id] = 1; dfs(v); } } void solve() { cin >> n >> m; for(ii i = 1; i <= m; i++) { ii u, v; cin >> u >> v; g[u].pb(mp(v,i)); g[v].pb(mp(u,i)); } dfs(1); for(ii i = 1; i <= vec.size(); i++) { ii x = vec[i-1]; if(lt[x] != 0) { nx[lt[x]] = i; vlr.pb(mp(lt[x],i-1)); lt[x] = 0; } else { lt[x] = i; } } for(auto X : vlr) { ii l = X.fr; ii r = X.sc; // cout << l << " - " << r << endl; vector<pair<ii,ii>> ans; bool ok = true; for(ii i = l; i <= r; i++) { if(nx[i] == 0) { ans.pb(mp(vec[i-1],i)); } else { if(nx[i] <= r) i = nx[i]-1; else if(!mark[i]) ans.pb(mp(vec[i-1],i)); else ok = false; } } if(!ok) continue; for(auto x : ans) { cout << x.fr << " "; mark[x.sc] = 1; } cout << endl; } } int main() { ios::sync_with_stdio(false); cin.tie(0); // freopen("in.in", "r", stdin); //freopen("out.out", "w", stdout); ii tt = 1; // cin >> tt; while(tt--) solve(); }

Compilation message (stderr)

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