Submission #1083539

#TimeUsernameProblemLanguageResultExecution timeMemory
1083539jay22Friend (IOI14_friend)C++14
Compilation error
0 ms0 KiB
#include <iostream>
#include <algorithm>

const int LEN = 100'000;
int N, w[LEN], dp[LEN][2], host[LEN], protocol[LEN];

int main() {
	std::cin >> N;
	for (int i = 0; i < N; ++i) std::cin >> w[i];
	for (int i = 1; i < N; ++i) std::cin >> host[i] >> protocol[i];
	for (int i = N - 1; i; --i) {
		if (protocol[i] == 0) {
			dp[host[i]][1] += dp[i][0];
			dp[host[i]][0] += std::max(dp[i][0], dp[i][1] + w[i]);
		}
		if (protocol[i] == 1) {
			dp[host[i]][0] += dp[i][0];
			dp[host[i]][1] += std::max(dp[i][0], dp[i][1] + w[i]);
		}
		if (protocol[i] == 2) {
			dp[host[i]][0] += dp[i][0];
			dp[host[i]][1] += std::max(dp[i][0], dp[i][1]);
            w[host[i]] = std::max(w[host[i]], w[i]);
		}
	}

	std::cout << std::max(dp[0][0], dp[0][1] + w[0]);
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cc3odwqw.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccoBEljx.o:friend.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc3odwqw.o:(.bss+0x0): multiple definition of `protocol'; /tmp/ccoBEljx.o:(.bss+0x0): first defined here
/usr/bin/ld: /tmp/cc3odwqw.o:(.bss+0x61aa0): multiple definition of `host'; /tmp/ccoBEljx.o:(.bss+0x61a80): first defined here
/usr/bin/ld: /tmp/cc3odwqw.o: in function `main':
grader.cpp:(.text.startup+0xdd): undefined reference to `findSample(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status