This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("a.gir","r",stdin);freopen ("a.cik","w",stdout),fast;
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;
ll n,m,sum,t,ar[N],q,mark[N],dp[N];
vector<int> v[N];
// ll f(int ind,ll len)
// {
// if(!tut[ind])
// sum=max(sum,len);
// for(int i=0;i<v[ind].size();i++)
// f(v[ind][i],len+1);
// }
int main()
{
fast;
cin>>n>>m>>q;
fo(i,1,m)
{
int a,b;
cin>>a>>b;
v[b].pb(a);
}
while(q--)
{
int st,k;
cin>>st>>k;
fo(i,1,n)
dp[i]=0,mark[i]=0;
sum=0;
for(int j=1,a;j<=k;j++)
{
cin>>a;
mark[a]=1;
}
mark[st]=1;
// ll mk=0;
for(int i=1;i<=st;i++)
{
for(int j=0;j<v[i].size();j++)
{
ll x=v[i][j];
ll y=dp[x];
if(y)
y++;
// if(i==5)
// cout<<y<<endl;
if(!mark[x])
y=max(1ll,y);
dp[i]=max(dp[i],y);
}
}
// for(int i=0;i<v[5].size();i++)
// cout<<v[5][i]<<sp<<dp[v[5][i]]<<endl;
// cout<<endl;
// for(int i=1;i<=n;i++)
// cout<<dp[i]<<sp;
// cout<<endl<<endl;
cout<<dp[st]<<endl;
}
}
Compilation message (stderr)
bitaro.cpp: In function 'int main()':
bitaro.cpp:61:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<v[i].size();j++)
~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |