# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
215926 | SamAnd | Fire drill (LMIO18_sauga) | C++17 | 69 ms | 3064 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 m_p make_pair
const int N = 1003;
mt19937 rnd(3141);
int tt, n, ss;
vector<int> a[N];
vector<int> v;
bool c[N];
void dfs(int x)
{
c[x] = true;
for (int i = 0; i < a[x].size(); ++i)
{
int h = a[x][i];
if (!c[h])
dfs(h);
}
v.push_back(x);
}
int main()
{
scanf("%d%d%d", &tt, &n, &ss);
for (int i = 1; i <= n; ++i)
{
int q;
scanf("%d", &q);
while (q--)
{
int x;
scanf("%d", &x);
a[i].push_back(x);
}
}
for (int i = 1; i <= n; ++i)
{
if (!c[i])
dfs(i);
}
for (int i = 0; i < n; ++i)
printf("%d\n", v[i]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |