Submission #231032

#TimeUsernameProblemLanguageResultExecution timeMemory
231032PajarajaSenior Postmen (BOI14_postmen)C++17
100 / 100
500 ms46504 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; vector<long long> g[500007]; int dk[500007]; stack<int> st,sk; bool vi[500007],vig[500007]; inline void euler(int s) { while(dk[s]<g[s].size()) { if(!vig[g[s][dk[s]]>>32LL]) { vig[g[s][dk[s]]>>32LL]=true; euler(g[s][dk[s]++]&((1LL<<32LL)-1)); } else dk[s]++; } st.push(s); } int main() { int n,m; scanf("%d%d",&n,&m); for(int i=0;i<m;i++) { int t1,t2; scanf("%d%d",&t1,&t2); g[t1].push_back(t2+(((long long)i)<<32LL)); g[t2].push_back(t1+(((long long)i)<<32LL)); } euler(1); for(int i=0;i<m+1;i++) { int x=st.top(); st.pop(); if(vi[x]) { while(true) { int y=sk.top(); printf("%d ",y); sk.pop(); vi[y]=false; if(y==x) break; } printf("\n"); } sk.push(x); vi[x]=true; } }

Compilation message (stderr)

postmen.cpp: In function 'void euler(int)':
postmen.cpp:10:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while(dk[s]<g[s].size())
        ~~~~~^~~~~~~~~~~~
postmen.cpp: In function 'int main()':
postmen.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
postmen.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&t1,&t2);
   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...