# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
932797 |
2024-02-24T09:05:09 Z |
vjudge1 |
Friend (IOI14_friend) |
C++17 |
|
0 ms |
0 KB |
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define F first
#define S second
#define ll long long
// #define int ll
#define pb push_back
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define mem(a,i) memset(a,i,sizeof(a))
#define in insert
#define lb lower_bound
#define ub upper_bound
#define y1 yy
#define ppb pop_back
#define ull unsigned ll
const int MAX=1e5+55;
const int inf=1e9;
const int N=2e5;
const int C=331;
const int C1=431;
const int mod=1e9+9;
const int mod1=1e9+9;
#include "friend.h"
int dp[MAX][2];
vector<pii> g[MAX];
int a[MAX];
void dfs(int v,int p=-1){
for(auto to:g[v]){
if(to.F==p)continue;
dfs(to.F,v);
dp[v][0]+=max(dp[to.F][0],dp[to.F][1]);
if(to.S==0)dp[v][1]+=dp[to.F][0];
else dp[v][1]+=max(dp[to.F][0],dp[to.F][1]);
}
dp[v][1]+=a[v];
}
int d[MAX][MAX];
int bit(int i,int j){
return (i>>j)&1;
}
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
if(n<=10){
for(int i=1;i<n;i++){
if(protocol[i]!=1){
d[i][host[i]]=1;
d[host[i]][i]=1;
}
if(protocol[i]!=0){
for(int j=0;j<n;j++){
if(d[host[i]][j]){
d[j][i]=1;
d[i][j]=1;
}
}
}
}
int ans=0;
for(int mask=0;mask<(1<<n);mask++){
int w=0;
bool ok=1;
for(int i=0;i<n;i++){
if(bit(mask,i))w+=confidence[i];
for(int j=i+1;j<n;j++){
if(bit(mask,i)&&bit(mask,j)&&d[i][j])ok=0;
}
}
if(ok)ans=max(ans,w);
}
return ans;
}
for(int i=0;i<n;i++)a[i]=confidence[i];
for(int i=1;i<n;i++){
if(protocol[i]==0){
g[i].pb({host[i],0});
g[host[i]].pb({i,0});
}
else{
g[host[i]].pb({i,1});
g[i].pb({host[i],1});
}
}
dfs(0);
return max(dp[0][0],dp[0][1]);
}
Compilation message
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status