Submission #539300

# Submission time Handle Problem Language Result Execution time Memory
539300 2022-03-18T16:21:18 Z Lobo Cats or Dogs (JOI18_catdog) C++17
Compilation error
0 ms 0 KB
#include "catdog.h"
#include<bits/stdc++.h>
using namespace std;

const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

#define maxn 1010

int n, dp[maxn][3], ct[maxn], dg[maxn];
vector<int> g[maxn];

void dfs(int u, int ant) {
    //dp(u,0) = u é C
    //dp(u,1) = u é D
    if(ct[u] == 1) dp[u][0] = 0, dp[u][1] = inf;
    else if(dg[u] == 1) dp[u][0] = inf, dp[u][1] = 0;
    else dp[u][0] = 0, dp[u][1] = 0;
    for(auto v : g[u]) {
        if(v == ant) continue;
        dfs(v,u);
        dp[u][0]+= min(dp[v][0],1+dp[v][1]);
        dp[u][1]+= min(dp[v][1],1+dp[v][0]);
    }
}

int cat(int v) {
    ct[v] = 1;
    dfs(1,1);
    return min(dp[1][0],dp[1][1]);
}

int dog(int v) {
    dg[v] = 1;
    dfs(1,1);
    return min(dp[1][0],dp[1][1]);
}

int neighbor(int v) {
    ct[v] = 0;
    dg[v] = 0;
    dfs(1,1);
    return min(dp[1][0],dp[1][1]);
}

void Initialize(int N, vector<int> A, vector<int> B) {
    n = N;
    for(int i = 0; i < n-1; i++) {
        g[A[i]].pb(B[i]);
        g[B[i]].pb(A[i]);
    }
}

// int32_t main() {
//     // ios::sync_with_stdio(false); cin.tie(0);

//     freopen("in.in", "r", stdin);
//     // freopen("out.out", "w", stdout);

//     int N; cin >> N;
//     int A[N-1], B[N-1];
//     for(int i = 0; i < N-1; i++) {
//         cin >> A[i] >> B[i];
//     }
//     Initialize(N,A,B);
//     int Q; cin >> Q;
//     while(Q--) {
//         int op,v;
//         cin >> op >> v;
//         if(op == 1) cout << cat(v) << endl;
//         if(op == 2) cout << dog(v) << endl;
//         if(op == 3) cout << neighbor(v) << endl;
//     }

// }

Compilation message

/usr/bin/ld: /tmp/ccFhibBX.o: in function `main':
grader.cpp:(.text.startup+0x1e2): undefined reference to `initialize(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: grader.cpp:(.text.startup+0x219): undefined reference to `neighbor(int)'
/usr/bin/ld: grader.cpp:(.text.startup+0x25e): undefined reference to `dog(int)'
/usr/bin/ld: grader.cpp:(.text.startup+0x269): undefined reference to `cat(int)'
collect2: error: ld returned 1 exit status