Submission #1172789

#TimeUsernameProblemLanguageResultExecution timeMemory
1172789TsaganaBitaro’s Party (JOI18_bitaro)C++20
14 / 100
2097 ms8264 KiB
#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second

using namespace std;

vector<int> adj[100010];
int dp[100010];
int ok[100010];

void solve () {
	int n, m, q;
	cin >> n >> m >> q;
	for (int i = 1; i <= m; i++) {
		int a, b;
		cin >> a >> b;
		if (a > b) swap(a, b);
		adj[b].pb(a);
	}
	while (q--) {
		int t, y;
		cin >> t >> y;
		for (int i = 1; i <= t; i++) dp[i] = ok[i] = 0;
		for (int i = 1; i <= y; i++) {int x; cin >> x; ok[x] = 1;}
		for (int i = 1; i <= t; i++) {
			for (auto j: adj[i]) dp[i] = max(dp[i], dp[j] + 1);
			if (!dp[i] && ok[i]) dp[i] = -1;
		}
		cout << dp[t] << '\n';
	}
}
signed main() {IOS solve(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...