이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2,fma")
#include"bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define endl '\n'
#define mod 1000000007
//\
#define mod 1686876991
const int maxn = 200001;
int n, m, q;
vector<int> adj[maxn], radj[maxn];
int dp[maxn];
signed main () {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m >> q;
for (int i = 0 ; i < m ; i++) {
int a, b;
cin >> a >> b;
adj[a].push_back(b);
radj[b].push_back(a);
}
while (q--) {
int t, y, c;
cin >> t >> y;
memset(dp, 0, sizeof dp);
for (int i = 0 ; i < y ; i++) cin >> c, dp[c] = -1e8;
for (int i = 1 ; i <= n ; i++) {
for (int j : radj[i]) {
dp[i] = max(dp[i], dp[j] + 1);
}
}
if (dp[t] < 0) cout << -1 << endl;
else cout << dp[t] << endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
bitaro.cpp:17:1: warning: multi-line comment [-Wcomment]
17 | //\
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |