Submission #363244

# Submission time Handle Problem Language Result Execution time Memory
363244 2021-02-05T11:32:24 Z teewar Cats or Dogs (JOI18_catdog) C++14
Compilation error
0 ms 0 KB
#include "catdog.h"

using namespace std;

const int MAX = 1000;
const int INF = 1e9;

vector<int> g[MAX + 10];
int best[MAX + 10];
int st[MAX + 10];



void dfs(int v, int p = -1) {
    d[v][st[v]] = 0;
    if(st[v] == 0) {
        d[v][1] = d[v][2] = 0;
    }
    for(auto to: g[v]) {
        if(p == to) {
            continue;
        }
        dfs(to, v);
        d[v][st[v]] += min({d[to][0], d[to][1] + 1, d[to][2] + 1, d[to][st[v]]});
        if(st[v] == 0) {
            d[v][1] += min({d[to][0], d[to][1] + 1, d[to][2] + 1, d[to][1]});
            d[v][1] += min({d[to][0], d[to][1] + 1, d[to][2] + 1, d[to][2]});
        }
    }
}


int ans() {
    for(int i = 0; i < MAX; ++i) {
        for(int j = 0; j < 3; ++j) {
            d[i][j] = INF;
        }
    }
    dfs(0);
    return min({d[0][0], d[0][1], d[0][2]});
}

void initialize(int n, vector<int> a, vector<int> b) {
    for(int i = 0; i < n - 1; ++i) {
        g[a[i] - 1].push_back(b[i] - 1);
    }
}

int cat(int v){
    --v;
    st[v] = 1;
    return ans();
}


int dog(int v) {
    --v;
    st[v] = 2;
    return ans();
}


int neighbor(int v) {
    --v;
    st[v] = 0;
    return ans();
}

Compilation message

catdog.cpp: In function 'void dfs(int, int)':
catdog.cpp:15:5: error: 'd' was not declared in this scope
   15 |     d[v][st[v]] = 0;
      |     ^
catdog.cpp:24:80: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   24 |         d[v][st[v]] += min({d[to][0], d[to][1] + 1, d[to][2] + 1, d[to][st[v]]});
      |                                                                                ^
In file included from /usr/include/c++/9/vector:60,
                 from catdog.h:3,
                 from catdog.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
catdog.cpp:24:80: note:   candidate expects 2 arguments, 1 provided
   24 |         d[v][st[v]] += min({d[to][0], d[to][1] + 1, d[to][2] + 1, d[to][st[v]]});
      |                                                                                ^
In file included from /usr/include/c++/9/vector:60,
                 from catdog.h:3,
                 from catdog.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
catdog.cpp:24:80: note:   candidate expects 3 arguments, 1 provided
   24 |         d[v][st[v]] += min({d[to][0], d[to][1] + 1, d[to][2] + 1, d[to][st[v]]});
      |                                                                                ^
catdog.cpp:26:76: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   26 |             d[v][1] += min({d[to][0], d[to][1] + 1, d[to][2] + 1, d[to][1]});
      |                                                                            ^
In file included from /usr/include/c++/9/vector:60,
                 from catdog.h:3,
                 from catdog.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
catdog.cpp:26:76: note:   candidate expects 2 arguments, 1 provided
   26 |             d[v][1] += min({d[to][0], d[to][1] + 1, d[to][2] + 1, d[to][1]});
      |                                                                            ^
In file included from /usr/include/c++/9/vector:60,
                 from catdog.h:3,
                 from catdog.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
catdog.cpp:26:76: note:   candidate expects 3 arguments, 1 provided
   26 |             d[v][1] += min({d[to][0], d[to][1] + 1, d[to][2] + 1, d[to][1]});
      |                                                                            ^
catdog.cpp:27:76: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   27 |             d[v][1] += min({d[to][0], d[to][1] + 1, d[to][2] + 1, d[to][2]});
      |                                                                            ^
In file included from /usr/include/c++/9/vector:60,
                 from catdog.h:3,
                 from catdog.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
catdog.cpp:27:76: note:   candidate expects 2 arguments, 1 provided
   27 |             d[v][1] += min({d[to][0], d[to][1] + 1, d[to][2] + 1, d[to][2]});
      |                                                                            ^
In file included from /usr/include/c++/9/vector:60,
                 from catdog.h:3,
                 from catdog.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
catdog.cpp:27:76: note:   candidate expects 3 arguments, 1 provided
   27 |             d[v][1] += min({d[to][0], d[to][1] + 1, d[to][2] + 1, d[to][2]});
      |                                                                            ^
catdog.cpp: In function 'int ans()':
catdog.cpp:36:13: error: 'd' was not declared in this scope
   36 |             d[i][j] = INF;
      |             ^
catdog.cpp:40:17: error: 'd' was not declared in this scope
   40 |     return min({d[0][0], d[0][1], d[0][2]});
      |                 ^
catdog.cpp:40:43: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   40 |     return min({d[0][0], d[0][1], d[0][2]});
      |                                           ^
In file included from /usr/include/c++/9/vector:60,
                 from catdog.h:3,
                 from catdog.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
catdog.cpp:40:43: note:   candidate expects 2 arguments, 1 provided
   40 |     return min({d[0][0], d[0][1], d[0][2]});
      |                                           ^
In file included from /usr/include/c++/9/vector:60,
                 from catdog.h:3,
                 from catdog.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
catdog.cpp:40:43: note:   candidate expects 3 arguments, 1 provided
   40 |     return min({d[0][0], d[0][1], d[0][2]});
      |                                           ^