Submission #998924

#TimeUsernameProblemLanguageResultExecution timeMemory
998924enviflyBitaro’s Party (JOI18_bitaro)C++17
0 / 100
2 ms5212 KiB
#pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> #ifdef UwU #include "C:\genshin_impact\keqing.cpp" #else #define debug(...) 0 #endif using namespace std; using ll = long long; const int MOD = 1e9 + 7; const int INF = 1e9; const ll INFLL = 1e18; #define F first #define S second #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define pb push_back #define FOR(i,a,b) for(int i = (a); i < (b); ++i) #define FORE(i,a,b) for(int i = (a); i <= (b); ++i) #define ROF(i,a,b) for(int i = (a); i >= (b); --i) #define trav(a,x) for(auto& a: x) #define sz(x) (int)x.size() #define make_unique(v) sort(all(v)); v.erase(unique(all(v)), v.end()) template<class T> using minpq = priority_queue<T, vector<T>, greater<T>>; template<class T> bool ckmin(T& a, const T& b){return b<a?a=b,1:0;} template<class T> bool ckmax(T& a, const T& b){return a<b?a=b,1:0;} template<int D, typename T>struct vt : public vector<vt<D - 1, T>> { template<typename... Args> vt(int n = 0, Args... args) : vector<vt<D - 1, T>>(n, vt<D - 1, T>(args...)) {}}; template<typename T> struct vt<1, T> : public vector<T> { vt(int n = 0, const T& val = T()) : vector<T>(n, val) {}}; template<typename T> istream& operator>>(istream& in, vector<T>& a) {for(auto &x : a) in >> x; return in;}; template<typename T> ostream& operator<<(ostream& out, vector<T>& a) {for(auto &x : a) out << x << ' '; return out;}; const int N = 1e5 + 5; vector<int> g[N], rg[N]; void solve() { int n, m, q; cin >> n >> m >> q; FOR(i,0,m){ int u, v; cin >> u >> v; --u; --v; g[u].pb(v); rg[v].pb(u); } while(q--){ int x; cin >> x; --x; int c; cin >> c; vector<int> v(c); trav(i, v) cin >> i, --i; vector<bool> blocked(n); trav(i, v) blocked[i] = 1; vector<int> dp(n), deg(n); ROF(i,x,0) trav(j, rg[i]) deg[j]++; queue<int> q; q.push(x); while(!q.empty()){ int f = q.front(); q.pop(); if(!deg[f]){ trav(i, rg[f]){ ckmax(dp[i], dp[f] + 1); --deg[i]; if(!deg[i]) q.push(i); } } } int ans = -1; ROF(i,x,0) if(!blocked[i]) ckmax(ans, dp[i]); cout << ans << "\n"; } } signed main() { cin.tie(0) -> sync_with_stdio(0); int t = 1; //cin >> t; for(int test = 1; test <= t; test++){ solve(); } } /* /\_/\ * (= ._.) * / > \> */

Compilation message (stderr)

bitaro.cpp:86:9: warning: "/*" within comment [-Wcomment]
   86 | /*   /\_/\
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...