이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |