Submission #704188

#TimeUsernameProblemLanguageResultExecution timeMemory
704188boyliguanhanSenior Postmen (BOI14_postmen)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #pragma GCC optimize(2) using namespace std; set<int> adj[500100]; int deg[500100]; stack<int> sol; int read(){ int res = 0, c = getchar_unlocked(); while(c < '0' || c > '9') c = getchar_unlocked(); while(isdigit(c)) res = res*10+c - 48, c = getchar_unlocked(); } void reverse(){ stack<int> temp; while(sol.size()) temp.push(sol.top()), sol.pop(); sol = temp; } void print(){ stack<int> now; bitset<500100> appeared; while(sol.size()){ if(appeared[sol.top()]){ printf("%d", sol.top()); while(now.top()!=sol.top()) printf(" %d", now.top()), appeared[now.top()] = 0, now.pop(); printf("\n"); } else { appeared[sol.top()] = 1; now.push(sol.top()); } sol.pop(); } } void dfs(int n){ while(adj[n].size()){ int i = *adj[n].begin(); adj[n].erase(i); adj[i].erase(n); dfs(i); } sol.push(n); } int main(){ int n = read(), m = read(); for(int i = 0; i < m; i++) { int a = read(),, b = read(); adj[a].insert(b); adj[b].insert(a); deg[a]++; deg[b]++; } dfs(1); reverse(); print(); return 0; }

Compilation message (stderr)

postmen.cpp: In function 'int read()':
postmen.cpp:13:1: warning: no return statement in function returning non-void [-Wreturn-type]
   13 | }
      | ^
postmen.cpp: In function 'int main()':
postmen.cpp:48:24: error: expected unqualified-id before ',' token
   48 |         int a = read(),, b = read();
      |                        ^
postmen.cpp:46:9: warning: unused variable 'n' [-Wunused-variable]
   46 |     int n = read(), m = read();
      |         ^