Submission #890132

#TimeUsernameProblemLanguageResultExecution timeMemory
890132LeVanThucBitaro’s Party (JOI18_bitaro)C++14
14 / 100
57 ms24404 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define p(x,y) pair<ll,ll>(x,y) #define BIT(i,x) ((x>>i)&1) #define MASK(x) (1<<x) #define ld long double #define __builtin_popcount __builtin_popcountll #define pll pair<ll,ll> template<class T1,class T2> bool maximize(T1 &x,T2 y) { if(x<y) { x=y; return 1; } return 0; } template<class T1,class T2> bool minimize(T1 &x,T2 y) { if(y<x) { x=y; return 1; } return 0; } const ll M=1e9+7; template <class T1,class T2> void add(T1 &x,T2 y) { x+=y; if(x>=M) x-=M; } template <class T1,class T2> void sub(T1 &x, T2 y) { x-=y; if(x<0) x+=M; } void online() { std::ios_base::sync_with_stdio(0); cin.tie(0); #ifdef thuc freopen("input.inp","r",stdin); freopen("output.out","w",stdout); #else #endif // thuc } const ll N=2e5+10; ll vs[N],f[N],ban[N],n,m,q,src; vector<ll> gr[N],rgr[N]; ll solve1(ll u) { if(vs[u]) return f[u]; vs[u]=1; f[u]=-1e9; if(u==src) return f[u]=0; for(auto v:gr[u]) { maximize(f[u],solve1(v)+1); maximize(f[u],solve1(v)+1); } return f[u]; } ll tr(ll u,ll y) { src=u; for(int i=1;i<=n;i++) { ban[i]=0; vs[i]=0; } for(int i=1;i<=y;i++) { ll x; cin>>x; ban[x]=1; } ll ans=-1; for(int i=1;i<=n;i++) { if(!ban[i])maximize(ans,solve1(i)); } return ans; } bool sub2() { for(int i=1;i<=m;i++) { ll u,v; cin>>u>>v; if(u>v) swap(u,v); gr[u].push_back(v); } ll t,y; cin>>t>>y; cout<<tr(t,y); return 0; } int main() { online(); cin>>n>>m>>q; if(q==1) return sub2(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...