Submission #197882

# Submission time Handle Problem Language Result Execution time Memory
197882 2020-01-24T02:44:39 Z Masterdan Friend (IOI14_friend) C++14
Compilation error
0 ms 0 KB
#include "friend.h"
#include <bits/stdc++.h>
// Find out best sample
#define all(a)  a.begin (),a.end ()
#define MIN -1
#define MAX 1e9+7
#define F first
#define S second
#define mk make_pair()
#define pb push_back
#define mem(a, c) memset(a, 0, sizeof( a))
using namespace std;
typedef vector <int> vi;
typedef pair<int, int> ii;
#include <cstdio>
#include <cassert>
#define __MAXSIZE__ 100002

using namespace std;

// Confidence
int confidence[__MAXSIZE__];

// Host
int host[__MAXSIZE__];

// Protocol
int protocol[__MAXSIZE__];
int vis[101000];
vector <vector <int> >G;
int dfs(int x, int maxi){
    vis[x]=1;
    maxi=max(maxi, confidence[x]);
    for(int i=0;i<G[x].size ();i++){
        int u=G[x][i];
        if(vis[u]==0)maxi=max(maxi, dfs(u,maxi));
    }return maxi;
}
int findSample(int n,int confi[],int host[],int prot[]){
        G=vector <vector<int> > (n+2);
       int sw=0;
       int s=0;
       for(int i=0;i<n;i++){
            s+=confi[i];
       }
       for(int i=1;i<n;i++){
        if(prot[i]!=0)sw=1;
       }
       if(!sw){
            return s;
       }
       else{
        for(int i=1;i<n;i++){
            G[host[i]].pb(i);
        }
        mem(vis, 0);
        int s=0;
            for(int i=0;i<n;i++){
                if(vis[i]==0)s+=dfs(i, -1);
            }
            return s;
       }
}

/*
// Main
int main(void)
{
	int n,i;

	// Number of people
	assert(scanf("%d",&n)==1);

	// Confidence
	for(i=0;i<n;i++)
		assert(scanf("%d",&confidence[i])==1);

	// Host and Protocol
	for(i=1;i<n;i++)
		assert(scanf("%d %d",&host[i],&protocol[i])==2);

	// Answer
	printf("%d\n",findSample(n,confidence,host,protocol));
	return 0;
}

*/

Compilation message

friend.cpp: In function 'int dfs(int, int)':
friend.cpp:34:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<G[x].size ();i++){
                 ~^~~~~~~~~~~~~
/tmp/ccYv7fg1.o:(.bss+0xc3540): multiple definition of `confidence'
/tmp/cc1DaCjj.o:(.bss+0x125f80): first defined here
/tmp/ccYv7fg1.o:(.bss+0x61aa0): multiple definition of `host'
/tmp/cc1DaCjj.o:(.bss+0xc44e0): first defined here
/tmp/ccYv7fg1.o:(.bss+0x0): multiple definition of `protocol'
/tmp/cc1DaCjj.o:(.bss+0x62a40): first defined here
collect2: error: ld returned 1 exit status