제출 #334323

#제출 시각아이디문제언어결과실행 시간메모리
334323maitandat03Bitaro’s Party (JOI18_bitaro)C++14
14 / 100
96 ms10988 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pli = pair< long long, int >; using pii = pair< int, int >; struct query { int t, y, i; vector< int > c; }; const int N = 1e5 + 7; int n, m, Q, res; vector< int > g[N]; query q[N]; int d[N]; bool notvisit[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("BITARO.inp", "r", stdin); // freopen("BITARO.out", "w", stdout); cin >> n >> m >> Q; for (int i = 1; i <= m; ++i) { int u, v; cin >> u >> v; g[v].push_back(u); } for (int i = 1; i <= Q; ++i) { int tmp; cin >> q[i].t >> q[i].y; for (int j = 1; j <= q[i].y; ++j) { cin >> tmp; // if (tmp <= q[i].t) // q[i].c.push_back(tmp); notvisit[tmp] = true; } q[i].i = i; } d[ q[1].t ] = 1; for (int u = q[1].t; u; --u) { if (!d[u]) continue; for (int v : g[u]) d[v] = max(d[v], d[u] + 1); if (!notvisit[u]) res = max(res, d[u]); } --res; if (!res && notvisit[ q[1].t ]) res = -1; cout << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...