제출 #1053153

#제출 시각아이디문제언어결과실행 시간메모리
1053153Huseyn123열쇠 (IOI21_keys)C++17
37 / 100
80 ms19808 KiB
#include <bits/stdc++.h> using namespace std; const int N=2001; int a[N],b[N],d[N],cnt[N]; vector<int> R,C; vector<vector<pair<int,int>>> g(N),e(N); void dfs(int v){ d[v]=1; if(b[R[v]]==0){ for(auto x:e[R[v]]){ if(d[x.first]+d[x.second]==1){ if(d[x.first]){ dfs(x.second); } else{ dfs(x.first); } } } } b[R[v]]=1; for(auto x:g[v]){ if(d[x.first] || b[x.second]==0){ continue; } dfs(x.first); } } vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { R=r; C=c; int n=(int)r.size(); int m=(int)c.size(); for(int i=0;i<m;i++){ g[u[i]].push_back({v[i],c[i]}); g[v[i]].push_back({u[i],c[i]}); e[c[i]].push_back({u[i],v[i]}); } vector<int> ans(r.size(), 1); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ a[j]=b[j]=d[j]=0; } dfs(i); for(int j=0;j<n;j++){ cnt[i]+=d[j]; } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(cnt[i]>cnt[j]){ ans[i]=0; } } } 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...