Submission #567096

#TimeUsernameProblemLanguageResultExecution timeMemory
567096Abdulmohsen1284Bitaro’s Party (JOI18_bitaro)C++14
0 / 100
3 ms4948 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]; 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++) { long long plc; cin>>plc; if(plc<t) bad[plc]=true; } 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; } if(!bad[t]) cout<<num[t]<<"\n"; else cout<<"-1\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...