Submission #790366

#TimeUsernameProblemLanguageResultExecution timeMemory
790366baneSenior Postmen (BOI14_postmen)C++17
0 / 100
18 ms26196 KiB
#include<bits/stdc++.h> using namespace std; #ifdef LOCAL #include "algo/debug.h" #else #define debug(...) 42 #endif #define fr first #define sc second #define mp make_pair #define pb push_back #define pf push_front #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(), x.rend() #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("Ofast,unroll-loops") using ll = long long; using ull = unsigned long long; using str = string; using pii = pair<int,int>; using pll = pair<long long, long long>; const int nax = 500'001; vector<int>flag(nax); vector<set<int>>adj(nax); vector<int>pracka; void Euler(int v){ while(!adj[v].empty()){ int x = *adj[v].begin(); adj[x].erase(v); adj[v].erase(x); Euler(x); } pracka.pb(v); } void solve(){ int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < m; i++){ int a,b; scanf("%d%d", &a, &b); --a,--b; adj[a].insert(b); adj[b].insert(a); } Euler(0); int r = -1; vector<vector<int>>cycles; vector<int>visited(n + 1); stack<int>c; while(r < (int)pracka.size()){ ++r; if (visited[pracka[r]]){ cycles.push_back(vector<int>()); cycles.back().push_back(pracka[r]); while(c.top() != pracka[r]){ visited[c.top()] = 0; cycles.back().push_back(c.top()); c.pop(); } }else{ c.push(pracka[r]); visited[pracka[r]] = 1; } } for (int i = 0; i < (int)cycles.size() - 1; i++){ for (int j : cycles[i])printf("%d ", j + 1); printf("\n"); } } int main(){ solve(); return 0; }

Compilation message (stderr)

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