Submission #1123658

#TimeUsernameProblemLanguageResultExecution timeMemory
1123658ZeroCoolBitaro’s Party (JOI18_bitaro)C++20
0 / 100
5 ms6728 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ar array #define ld long double const int INF = 1e18 + 10; const int N = 2e5 + 20; const int SQRT = 400; int n, m, q; int dp[N]; vector<int> g[N]; void calc(int x){ memset(dp, -1, sizeof dp); dp[x] = 0; for(int i = x;i >= 0;i--){ for(auto u: g[i])dp[u] = max(dp[u], dp[i] + 1); } } signed main(){ios_base::sync_with_stdio(false);cin.tie(0); cin>>n>>m>>q; while(m--){ int a, b; cin>>a>>b; --a, --b; g[b].push_back(a); } for(int it = 1;it <= q;it++){ int x, y; cin>>x>>y; --x; calc(x); int d[n] = {0}; while(y--){ int t; cin>>t; --t; d[t] = 1; } int ans = -1; for(int i = 0;i < n;i++){ if(!d[i])ans = max(ans, dp[i]); } cout<<ans<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...