제출 #894857

#제출 시각아이디문제언어결과실행 시간메모리
894857Sir_Ahmed_Imran열쇠 (IOI21_keys)C++17
37 / 100
3032 ms40788 KiB
///~~~LOTA~~~/// #include "keys.h" #include <bits/stdc++.h> using namespace std; #define nl '\n' #define ff first #define ss second #define ll long long #define append push_back #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define N 300001 int t[N]; int z[N]; int vis[N]; vector<int> k[N]; vector<pii> a[N]; int dfs(int v){ if(vis[v]) return 0; vis[v]=t[z[v]]=1; int x=1; for(auto& i:k[z[v]]) x+=dfs(i); k[z[v]].clear(); for(auto& i:a[v]){ if(t[i.ss]) x+=dfs(i.ff); else k[i.ss].append(i.ff); } return x; } vector<int> find_reachable(vector<int> r,vector<int> u,vector<int> v,vector<int> c){ int n,m; n=r.size(); m=v.size(); for(int i=0;i<n;i++) z[i]=r[i]; for(int i=0;i<m;i++){ a[u[i]].append({v[i],c[i]}); a[v[i]].append({u[i],c[i]}); } vector<int> x,y; for(int i=0;i<n;i++){ x.append(dfs(i)); y.append(1); for(int j=0;j<n;j++){ vis[j]=t[j]=0; k[j].clear(); } } for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(x[j]<x[i]) y[i]=0; return y; }
#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...