This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |