# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1126487 | AndrijaM | Bitaro’s Party (JOI18_bitaro) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int maxn=2e5+10;
const int mod=1e9+7;
vector<int>g[maxn];
int dp[maxn];
int c[maxn];
vector<int>v[maxn];
int pdp[maxn];
void dfs(int node,int par)
{
for(auto ax:g[node])
{
if(ax==par)continue;
dfs(ax,node);
dp[node]=max(dp[node],dp[ax]+1);
}
}
signed main()
{
ios::sync_with_stdio(false);
int n,m,q;
cin>>n>>m>>q;
for(int i=0;i<m;i++)
{
int a,b;
cin>>a>>b;
a--;b--;
g[b].push_back(a);
}
for(int i=0;i<n;i++)
{
if(!)
{
f(i);
}
}
while(q--)
{
int st;
int kol;
cin>>st>>kol;
st--;
memset(dp,0,sizeof dp);
for(int i=0;i<kol;i++)
{
cin>>c[i];
c[i]--;
dp[c[i]]=-1e9;
}
if(kol>350)
{
///memset(dp,0,sizeof dp);
dfs(st,-1);
cout<<dp[st]<<endl;
continue;
}
}
return 0;
}