Submission #1041097

#TimeUsernameProblemLanguageResultExecution timeMemory
1041097AbitoBitaro’s Party (JOI18_bitaro)C++17
14 / 100
69 ms24768 KiB
#include <bits/stdc++.h> #define F first #define S second #define pb push_back #define ppb pop_back #define ep insert #define endl '\n' #define elif else if #define pow pwr #define sqrt sqrtt #define int long long #define ll long long #define y1 YONE typedef unsigned long long ull; using namespace std; const int N=1e5+5,S=300; int a[N],dp[N],ans[N][S],n,q,m; vector<int> adj[2][N]; bool vis[N],b[N]; int rec(int x){ if (vis[x]) return dp[x]; vis[x]=1; for (auto u:adj[0][x]) dp[x]=max(dp[x],rec(u)+1); return dp[x]; } int32_t main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin>>n>>m>>q; for (int i=1;i<=m;i++){ int x,y; cin>>x>>y; adj[0][x].pb(y); adj[1][y].pb(x); } int t,y; cin>>t>>y; for (int i=1;i<=n;i++) dp[i]=INT_MIN; dp[t]=0; for (int i=1;i<=n;i++) rec(i); //for (int i=1;i<=n;i++) cout<<dp[i]<<' ';cout<<endl; for (int i=1;i<=y;i++){ int x;cin>>x; b[x]=1; } int ans=-1; for (int i=1;i<=n;i++) if (!b[i]) ans=max(ans,dp[i]); cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...