Submission #291870

#TimeUsernameProblemLanguageResultExecution timeMemory
291870BlagojceSenior Postmen (BOI14_postmen)C++11
55 / 100
591 ms55780 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #define fr(i, n, m) for(int i = (n); i < (m); i ++) #define pb push_back #define st first #define nd second #define pq priority_queue #define all(x) begin(x), end(x) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; const ll inf = 1e18; const ll mod = 1000000007; const ld eps = 1e-13; const ld pi = 3.14159265359; mt19937 _rand(time(NULL)); clock_t timer = clock(); const int mxn = 5*1e5+5; int n, m; vector<int> g[mxn]; bool used[mxn]; int l[mxn], r[mxn]; vector<int> cycle; void euler(int u){ while(!g[u].empty()){ int e = g[u].back(); int v = l[e]; if(v == u) v = r[e]; g[u].pop_back(); if(used[e]) continue; used[e] = true; euler(v); } cycle.pb(u); } bool vis[mxn]; void restore(){ stack<int> S; for(auto u : cycle){ if(vis[u]){ while(1){ int x = S.top(); printf("%d ", x+1); S.pop(); vis[x] = false; if(x == u){ printf("\n"); break; } } } vis[u] = true; S.push(u); } } void solve(){ scanf("%d %d", &n, &m); fr(i, 0, m){ scanf("%d %d", &l[i], &r[i]); --l[i], --r[i]; g[l[i]].pb(i); g[r[i]].pb(i); } euler(0); restore(); } int main(){ solve(); }

Compilation message (stderr)

postmen.cpp: In function 'void solve()':
postmen.cpp:69:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   69 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
postmen.cpp:71:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   71 |   scanf("%d %d", &l[i], &r[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...