Submission #669158

# Submission time Handle Problem Language Result Execution time Memory
669158 2022-12-05T20:54:13 Z tibinyte From Hacks to Snitches (BOI21_watchmen) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
//#include "catdog.h"
using namespace std;
const int inf = 1e9;
vector<int> a;
vector<vector<int>> g;
vector<vector<int>> dp;
void initialize(int N, vector<int> A, vector<int> B)
{
    g = vector<vector<int>>(N + 1);
    dp = vector<vector<int>>(N + 1, vector<int>(2));
    a = vector<int>(N + 1, 2);
    for (int i = 1; i <= N; ++i)
    {
        g[A[i]].emplace_back(B[i]);
        g[B[i]].emplace_back(A[i]);
    }
}
void dfs(int node, int parent)
{
    for (int i = 0; i < 2; ++i)
    {
        dp[node][i] = inf;
    }
    bool leaf = true;
    for (auto i : g[node])
    {
        if (i != parent)
        {
            dfs(i, node);
            for (int j = 0; j < 2; ++j)
            {
                dp[node][j] = min({dp[node][j], dp[i][j], dp[i][j ^ 1] + 1});
            }
            leaf = false;
        }
    }
    if (leaf)
    {
        if (a[node] == 2)
        {
            for (int i = 0; i < 1; ++i)
            {
                dp[node][i] = 0;
            }
        }
        else
        {
            dp[node][a[node]] = 0;
        }
    }
    if (a[node] != 2)
    {
        dp[node][a[node] ^ 1] = inf;
    }
}
int cat(int v)
{
    a[v] = 0;
    dfs(1, 0);
    return min(dp[1][0], dp[1][1]);
}

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

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

Compilation message

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status