Submission #1101645

#TimeUsernameProblemLanguageResultExecution timeMemory
1101645NurislamBitaro’s Party (JOI18_bitaro)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ss second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define int long long template <class F, class _S> bool chmin(F &u, const _S &v){ bool flag = false; if ( u > v ){ u = v; flag |= true; } return flag; } template <class F, class _S> bool chmax(F &u, const _S &v){ bool flag = false; if ( u < v ){ u = v; flag |= true; } return flag; } const int N = (1<<18) +1, inf = 1e17+200; //int mod = 998244353; //int mod = 1000000007; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define rnd(l, r) uniform_int_distribution <int> (l, r)(rng) signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); int n, m, q; cin >> n >> m >> q; vector<vector<int>> g(n+1); for(int i = 0; i < m; i++){ int u, v; cin >> u >> v; g[v].pb(u); } vector<int> vis(n+1); int ans = 0; auto calc = [&](int ps)-> void{ vector<int> ds(n+1, 0); priority_queue<array<int,2>> q; q.push({0, ps}); while(q.size()){ auto [d, p] = q.top(); q.pop(); if(ds[p] > p)continue; for(auto to:g[p]){ if(chmax(ds[to], ds[p]+1))q.push({ds[to], to}); } } for(int i = 1; i <= n; i++){ if(!vis[i])chmax(ans, ds[i]); } }; while(q--){ ans = 0; int x, sz; cin >> x >> sz; vector<int> ar(sz); for(int &i:ar)cin >> i; for(int i:ar)vis[i] = 1; calc(x); for(int i:ar)vis[i] = 0; cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...