제출 #560583

#제출 시각아이디문제언어결과실행 시간메모리
560583colossal_pepeBitaro’s Party (JOI18_bitaro)C++17
14 / 100
2067 ms7772 KiB
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
 
const int INF = 1e9;
 
int n, m, q;
vector<vector<int>> g;

int comptueAns(int t, bool is_busy[]) {
    int dp[t + 1];
    for (int u = 0; u <= t; u++) {
        dp[u] = -INF;
        for (int v : g[u]) {
            dp[u] = max(dp[u], dp[v] + 1);
        }
        if (not is_busy[u]) dp[u] = max(dp[u], 0);
    }
    return max(dp[t], -1);
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> q;
    g.resize(n);
    while (m--) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[v].push_back(u);
    }
    vector<int> busy_ppl;
    bool is_busy[n] = {0};
    while (q--) {
        int t, y;
        cin >> t >> y;
        t--;
        busy_ppl.resize(y);
        for (int &c : busy_ppl) {
            cin >> c;
            c--;
            is_busy[c] = 1;
        }
        cout << comptueAns(t, is_busy) << '\n';
        for (int &c : busy_ppl) {
            is_busy[c] = 0;
        }
        busy_ppl.clear();
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...