제출 #894846

#제출 시각아이디문제언어결과실행 시간메모리
894846Sir_Ahmed_Imran열쇠 (IOI21_keys)C++17
0 / 100
3 ms16984 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; for(int i=0;i<n;i++){ x.append(dfs(i)); for(int j=0;j<m;j++){ vis[i]=t[i]=0; k[i].clear(); } } return x; }
#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...