제출 #959388

#제출 시각아이디문제언어결과실행 시간메모리
959388irmuunBitaro’s Party (JOI18_bitaro)C++17
14 / 100
2078 ms20648 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n,m,q; cin>>n>>m>>q; ll s[m],e[m]; vector<ll>up[n+5],down[n+5]; for(ll i=0;i<m;i++){ cin>>s[i]>>e[i]; up[s[i]].pb(e[i]); down[e[i]].pb(s[i]); } vector<bool>vis(n+5,1); for(ll i=0;i<q;i++){ ll t,y; cin>>t>>y; ll c[y]; for(ll j=0;j<y;j++){ cin>>c[j]; vis[c[j]]=false; } ll ans=-1; vector<ll>dp(n+5,-1); dp[t]=0; for(ll j=t;j>=1;j--){ if(dp[j]>-1){ for(auto x:down[j]){ dp[x]=max(dp[x],dp[j]+1); } } } for(ll j=1;j<=n;j++){ if(dp[j]>-1&&vis[j]){ ans=max(ans,dp[j]); } } for(ll j=0;j<y;j++){ vis[c[j]]=true; } cout<<ans<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...