# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
982720 | alo_54 | Game (APIO22_game) | C++17 | 0 ms | 0 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 "game.h"
#include <bits/stdc++.h>
using namespace std;
struct Nodo
{
vector <int> ady;
bool special = false;
};
vector <Nodo> g;
int dfs(int node, int target, bool isSpecial)
{
//cout<<"call "<<node<<" "<<target<<endl;
if (node == target )
{
if (isSpecial or g[node].special)
{
return 1;
}
return 0;
}
if (g[node].special)
{
isSpecial = true;
}
for (auto i : g[node].ady)
{
if (dfs(i, target, isSpecial) == 1)
{
return 1;
}
}
return 0;
}
void init(int n, int k)
{
g.resize(n);
for (int i = 0; i < n; i++)
{
g[i].special = false;
}
for (int i = 0; i < k; i++)
{
g[i].special = true;
if (i != k - 1)
{
g[i].ady.push_back(i + 1);
}
}
}