Submission #438265

#TimeUsernameProblemLanguageResultExecution timeMemory
438265bobbilykingFriend (IOI14_friend)C++17
Compilation error
0 ms0 KiB
#include "friend.h" #include<bits/stdc++.h> using namespace std; #define N 100010 typedef long long int ll; ll cost[N], bip[N]; vector<ll> adj[N]; void dfs(int i, int p, int t){ if (bip[i]!=-1) return; bip[i] = t; for (int x: adj[i]){ if (x==p) continue; dfs(x,i,(t+1)&1); } } int findSample(int n, int c[], int h[], int p[]){ int sum = 0; ll mx = 0; int prot[3]; for (int i= 0 ; i < 3; i++) prot[i] = 0; for (int i = 0 ; i< n; i++) { cost[i] = c[i]; sum += c[i]; mx = max(mx,cost[i]); } for (int i =1; i < n; i++){ prot[p[i]]++; } int ans = 0; if (prot[0]==n-1){ ans = sum; } else if (prot[1]==n-1){ ans = mx; } else if (prot[2] == n-1){ for (int i = 1; i < n; i++){ adj[i].push_back(h[i]); adj[h[i]].push_back(i); } for (int i = 0 ; i < n; i+=1) bip[i] = -1; dfs(0,0,0); int s2 = 0; for (int i = 0; i < n; i+=1) if (bip[i] ==1)s2+=cost[i]; ans = max(s2,sum-s2); } return ans; } void readInput(){ int n; cin>>n; int c[n], h[n], p[n]; for (int i = 0; i < n; i++) cin>>c[i]; for (int i =0 ; i < n; i++) cin>>h[i]; for (int i =0; i < n; i++) cin>>p[i]; cout<<findSample(n,c,h,p)<<'\n'; } int main(){ readInput(); }

Compilation message (stderr)

/usr/bin/ld: /tmp/cctflT5E.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccYM2LbI.o:friend.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status