Submission #1094010

#TimeUsernameProblemLanguageResultExecution timeMemory
1094010___Bitaro’s Party (JOI18_bitaro)C++17
0 / 100
1 ms2648 KiB
#include <bits/stdc++.h>
#define int long long int
#define ff first
#define ss second
#define FT ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
int n , m , q;
const int maxn = 1e5 + 10;
vector <int> adj[maxn];
int dp[maxn];
bool mark[maxn];
void dfs (int v)
{
	for (auto u : adj[v])
	{
		dfs (u);
		dp[v] = max (dp[v] , dp[u] + 1);
	}
	
}
signed main() 
{
	FT;
	cin >> n >> m >> q;
	for (int i = 1 ; i <= m ; i++)
	{
		int s , e;
		cin >> s >> e;
		adj[e].push_back(s);
	}
	while (q--)
	{
		int t , y;
		cin >> t >> y;
		while (y--)
		{
			int c;
			cin >> c;
			mark[c] = true;
		}
		dfs (t);
		int ans = -1;
		for (int i = 1 ; i <= n ; i++)
		{
			if (!mark[i] && i != t)
			{
				ans = max (ans , dp[i]);
			}
		}
		cout << ans << "\n";
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...