Submission #204803

#TimeUsernameProblemLanguageResultExecution timeMemory
204803awlintqaaFriend (IOI14_friend)C++14
8 / 100
7 ms380 KiB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #include <bits/stdc++.h> using namespace std; #define sqr 200 #define mid (l+r)/2 #define pb push_back #define ppb pop_back #define fi first #define se second #define lb lower_bound #define ub upper_bound #define ins insert #define era erase #define C continue #define mem(dp,i) memset(dp,i,sizeof(dp)) #define mset multiset typedef long long ll; typedef short int si; typedef long double ld; typedef pair<int,int> pi; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; const ll mod=1e9+7; const ll inf= 4e18; const ld pai=acos(-1); #include "friend.h" int p[100009]; int mx[100009]; int get(int node){ if(p[node]==node)return node; return get(p[node]); } void merge(int a,int b){ a=get(a); b=get(b); if(a==b)return ; p[b]=a; mx[a]=max(mx[a],mx[b]); } int findSample(int n,int confidence[],int host[],int protocol[]){ for(int i=0;i<n;i++){ p[i]=i; mx[i]=confidence[i]; } for(int i=1;i<n;i++){ int a=i,b=host[i]; merge(a,b); } set<int>s; int ans=0; for(int i=0;i<n;i++){ int x=get(i); if(s.find(x)!=s.end())C; s.ins(x); ans+=mx[x]; } 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...
#Verdict Execution timeMemoryGrader output
Fetching results...