# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
231032 | Pajaraja | Senior Postmen (BOI14_postmen) | C++17 | 500 ms | 46504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |