Submission #129512

# Submission time Handle Problem Language Result Execution time Memory
129512 2019-07-12T11:38:20 Z antimirage Friend (IOI14_friend) C++14
Compilation error
0 ms 0 KB
#include "friend.h"
#include "grader.cpp"
#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e5 + 5;

vector <int> g[N], vec;

int u[N], dp[N][2], ans;

int bfs (int v) {
	
	int start = v;
	
	vec.clear();
	queue <int> q;
	q.push(v);
	u[v] = 1;
	
	while (!q.empty() ) {
		v = q.front();
		q.pop();
		vec.pb(v);
		for (auto to : g[v]) {
			if (u[to]) continue;
			u[to] = u[v] + 1;
			q.push(to);
		}
	}
	reverse(all(vec));
	
	for (auto it : vec) {
		v = it;
		for (auto to : g[v]) {
			if (u[to] > u[v]) {
				assert(u[to] - 1 == u[v]);
				dp[v][1] += dp[to][0];
				dp[v][0] += max(dp[to][1], dp[to][0]);
			}
			assert(u[to] != u[v]);
		}
	}
	return max(dp[start][0], dp[start][1]);
}

int findSample(int n, int val[], int batya[], int type[]) {
	
	assert(val[0] == 1);
	dp[0][1] = 1;
	for (int i = 1; i < n; i++) {
		dp[i][1] = 1;
		assert(val[i] == 1);
		
		if (type[i] == 0) {
			g[batya[i]].pb(i);
			g[i].pb(batya[i]);
		}
		else if (type[i] == 1) {
			for (auto it: g[batya[i]]) {
				g[i].pb(it);
				g[it].pb(i);
			}
		}
		else
			assert(0);
	}
	for (int i = 0; i < n; i++) {
		if (u[i]) continue;
		ans += bfs(i);
	}
	return ans;
}

Compilation message

/tmp/ccqev4dQ.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccGCSmzN.o:friend.cpp:(.text.startup+0x0): first defined here
/tmp/ccqev4dQ.o:(.bss+0xc3540): multiple definition of `confidence'
/tmp/ccGCSmzN.o:(.bss+0x4324e0): first defined here
/tmp/ccqev4dQ.o:(.bss+0x61aa0): multiple definition of `host'
/tmp/ccGCSmzN.o:(.bss+0x3d0a40): first defined here
/tmp/ccqev4dQ.o:(.bss+0x0): multiple definition of `protocol'
/tmp/ccGCSmzN.o:(.bss+0x36efa0): first defined here
collect2: error: ld returned 1 exit status