제출 #602369

#제출 시각아이디문제언어결과실행 시간메모리
602369rrrr10000Keys (IOI21_keys)C++17
37 / 100
3061 ms44192 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; typedef tuple<ll,ll,ll> PP; typedef vector<ll> vi; typedef vector<vi> vvi; typedef vector<bool> vb; typedef vector<P> vp; typedef vector<vp> vvp; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++) #define fi first #define se second #define pb emplace_back #define all(a) a.begin(),a.end() template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;} template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;} template<class T> void out(T a){cout<<a<<endl;} template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;} vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { ll n=r.size(),m=u.size(); vvp g(n); rep(i,m){ g[u[i]].pb(v[i],c[i]); g[v[i]].pb(u[i],c[i]); } vi p(n,n+1); rep(s,n){ vi tmp; vb seen(n,false),done(n,false),ok_c(n,false); vvi edges(n); function<bool(ll)> dfs1=[&](ll i){ tmp.pb(i); seen[i]=true; if(!ok_c[r[i]]){ ok_c[r[i]]=true; for(ll x:edges[r[i]])if(!seen[x]){ if(!dfs1(x))return false; } } for(auto x:g[i])if(!seen[x.fi]){ if(ok_c[x.se]){ if(!dfs1(x.fi))return false; } else{ edges[x.se].pb(x.fi); } } return true; }; bool res=dfs1(s); if(res){ for(ll x:tmp)chmin(p[x],(ll)(tmp.size())); } } ll mi=n+1; for(ll x:p)chmin(mi,x); vector<int> ans(n); rep(i,n)if(p[i]==mi)ans[i]=1; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...