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"
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>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
bool bad[2000005];
long long num[2000005],plc[200005];
vector <long long> tr[200005];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
long long n,m,q;
cin>>n>>m>>q;
for(int i=0;i<m;i++)
{
long long fr,sc;
cin>>fr>>sc;
if(fr<sc)
swap(fr,sc);
tr[sc].push_back(fr);
}
for(int i=0;i<q;i++)
{
long long t,y;
cin>>t>>y;
for(int j=0;j<y;j++)
{
cin>>plc[j];
if(plc[j]<=t)
bad[plc[j]]=true;
}
if(bad[t])
{
num[t]=-1;
}
for(int j=1;j<t;j++)
{
if(!bad[j])
{
for(auto k : tr[j])
{
if(k>t)
continue;
bad[k]=false;
num[k]=max(num[k],num[j]+1);
}
}
bad[j]=false;
num[j]=0;
}
cout<<num[t]<<"\n";
num[t]=0;
bad[t]=false;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |