제출 #567114

#제출 시각아이디문제언어결과실행 시간메모리
567114Abdulmohsen1284Bitaro’s Party (JOI18_bitaro)C++14
14 / 100
2084 ms10340 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...