Submission #526602

#TimeUsernameProblemLanguageResultExecution timeMemory
526602Aldas25Bitaro’s Party (JOI18_bitaro)C++14
14 / 100
2099 ms9428 KiB
#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 100100, MAXK = 40;
const int INF = 1e9;
//const ll MOD = 1e9+7;
//const ll MOD = 998244353;

//const int C = 300;
const int C = 0;

int n, m, q;
vi adj[MAXN];
bool busy[MAXN];
vi busySeq;
int dp[MAXN];

int main()
{
    FAST_IO;

    cin >> n >> m >> q;
    REP(m) {
        int s, e;
        cin >> s >> e;
        adj[s].pb(e);
    }

    REP(q) {
        int t, y;
        cin >> t >> y;

        busySeq.clear();
        REP(y) {
            int x; cin >> x;
            busySeq.pb(x);
            busy[x] = true;
        }

        if (y >= C) {
            FOR(i, 1, t) dp[i] = busy[i] ? (-1) : 0;

            FOR(i, 1, t) {
                if (dp[i] < 0) continue;
                for (int u : adj[i])
                    dp[u] = max(dp[u], dp[i] + 1);
            }

            cout << dp[t] << "\n";
        }


        for (int x : busySeq) busy[x] = false;

    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...