Submission #704193

#TimeUsernameProblemLanguageResultExecution timeMemory
704193boyliguanhanSenior Postmen (BOI14_postmen)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #pragma GCC optimize(2) #define getchar_unlocked _getchar_nolock using namespace std; vector<pair<int, int>> adj[500100]; bitset<500100> removed; int cnt[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(); return res; } 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){ for(int i = cnt[n]; i < adj[n].size(); i++) if(!removed[adj[n][i].second]) removed[adj[n][i].second] = 1, cnt[n] = i, dfs(adj[n][i].first); sol.push(n); } int main(){ int n = read(), m = read(); for(int i = 0; i < m; i++) { int a = read(), b = read(); adj[a].push_back({b, i}); adj[b].push_back({a, i}); } dfs(1); reverse(); print(); return 0; }

Compilation message (stderr)

postmen.cpp: In function 'int read()':
postmen.cpp:3:26: error: '_getchar_nolock' was not declared in this scope; did you mean 'getchar_unlocked'?
    3 | #define getchar_unlocked _getchar_nolock
      |                          ^~~~~~~~~~~~~~~
postmen.cpp:10:22: note: in expansion of macro 'getchar_unlocked'
   10 |     int res = 0, c = getchar_unlocked();
      |                      ^~~~~~~~~~~~~~~~
postmen.cpp: In function 'void dfs(int)':
postmen.cpp:40:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int i = cnt[n]; i < adj[n].size(); i++)
      |                         ~~^~~~~~~~~~~~~~~
postmen.cpp: In function 'int main()':
postmen.cpp:46:9: warning: unused variable 'n' [-Wunused-variable]
   46 |     int n = read(), m = read();
      |         ^