# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31555 | YoLo | Senior Postmen (BOI14_postmen) | C++98 | 1097 ms | 22496 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>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define N 100000
#define pi acos(-1)
#define tora acos(-1)/180
#define tode 180/acos(-1)
#define pque priority_queue
typedef pair < int, int > ii;
typedef vector < int > vi;
typedef vector < vi > vii;
int mod = 1000000007 ;
int check[500009], edge[500009], n, m, a, b, cak, x[500009], y[500009], f[500009], cnt;
vi v[500009];
void dfs(int u)
{
//cout << u << endl;
if(check[u] == 1)
{
if(cak == 1)
printf("\n");
printf("%d", u);
while(cnt > 0 && f[cnt] != u)
{
printf(" %d", f[cnt]);
check[f[cnt]] = 0;
f[cnt] = 0;
cnt --;
}
cak = 1;
}
else
{
check[u] = 1;
cnt ++;
f[cnt] = u;
}
for(int i = 0; i < (int)v[u].size(); i++)
if(edge[v[u][i]] == 0 && check[u] == 1)
{
edge[v[u][i]] = 1;
if(x[v[u][i]] != u)
dfs(x[v[u][i]]);
else
dfs(y[v[u][i]]);
}
}
int main()
{
//ios_base::sync_with_stdio(0);
cin >> n >> m;
for(int i = 1; i <= m; i++)
{
scanf("%d%d", &x[i], &y[i]);
v[x[i]].pb(i);
v[y[i]].pb(i);
}
for(int i = 1; i <= n; i++)
dfs(i);
}
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... |