Submission #1128063

#TimeUsernameProblemLanguageResultExecution timeMemory
1128063NurislamBitaro’s Party (JOI18_bitaro)C++17
7 / 100
2096 ms31816 KiB
#include <bits/stdc++.h> //#pragma GCC optimize("O3,unroll-loops") //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> using namespace std; //using namespace __gnu_pbds; #define int long long #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define ff first #define ss second #define pb push_back //#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> //#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> //#define double long double template<class T, class U> inline bool chmin(T& a, const U& b) { if (a > b) { a = b; return true; } return false; } template<class T, class U> inline bool chmax(T& a, const U& b) { if (a < b) { a = b; return true; } return false; } const int N = 1000002; //const int inf = 1e18; //const int mx = 1e13; //const int mod = 1e9 + 7; //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //#define rnd(l, r) uniform_int_distribution <int> (l, r)(rng) void solve(){ 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[u].pb(v); } vector<map<int,int>> mp(n+1); for(int i = 1; i <= n; i++)mp[i][i] = 0; vector<int> vs(n+1, 0); for(int i = 1; i <= n; i++){ for(auto to:g[i]){ for(auto [a, cnt] : mp[i]){ chmax(mp[to][a], cnt+1); } } } while(q--){ int x; cin >> x; int nm;cin >> nm; set<int> st; for(int i = 0; i < nm; i++){ int v; cin >> v; st.insert(v); } int ans = -1; for(auto [a, cn] : mp[x])if(!st.count(a))chmax(ans, cn); cout << ans << '\n'; }; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); int tt = 1; //cin >> tt; while(tt--){ solve(); }; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...