Submission #1182082

#TimeUsernameProblemLanguageResultExecution timeMemory
1182082tapilyocaFriend (IOI14_friend)C++20
Compilation error
0 ms0 KiB
/***********************************************
* auth: tapilyoca                              *
* date: 04/09/2025 at 21:26:08                 *
* dots: https://github.com/tapilyoca/dotilyoca * 
***********************************************/

#include <bits/stdc++.h>
#include "friend.h"
using namespace std;
const long long MOD = 1e9+7;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll,ll>;
using str = string;
#define dbg(x) cerr << #x << ": " << x << endl;

/***********************************************/

ll findSample(ll n, ll conf[], ll host[], ll p[]) {
    ll out = 0;

    ll take[n], notake[n];

    for(int i = 0; i < n; i++) {
        take[i] = conf[i];
        notake[i] = 0;    

        cerr << i << " " << take[i] << " " << notake[i] << endl;
    }

    for(int i = n-1; i >= 1; i--) {
        ll u = host[i];
        ll v = i;

        if(p[i] == 0) { // i am your friend
            // either take u, take v, or take none
            take[u] = take[u] + notake[v];
            notake[u] = max(notake[u] + notake[v], notake[u] + take[v]);
        }

        if(p[i] == 1) { // my friends are your friends
            // either take both, one, or none
            take[u] = max({take[u] + take[v], take[u] + notake[v], notake[u] + take[v]});
            notake[u] = notake[u] + notake[v];
        }

        if(p[i] == 2) { // we are your friends
            // either take u, take v, or take none
            take[u] = max(take[u] + notake[v], notake[u] + take[v]);
            notake[u] = notake[u] + notake[v];
        }
    }


    return max(take[0], notake[0]);
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccepsCrp.o: in function `main':
grader.cpp:(.text.startup+0xe5): undefined reference to `findSample(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status