답안 #363245

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
363245 2021-02-05T11:32:52 Z teewar Cats or Dogs (JOI18_catdog) C++14
컴파일 오류
0 ms 0 KB
#include "catdog.h"

using namespace std;

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

int d[MAX + 10][3];
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:25:80: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   25 |         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:25:80: note:   candidate expects 2 arguments, 1 provided
   25 |         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:25:80: note:   candidate expects 3 arguments, 1 provided
   25 |         d[v][st[v]] += min({d[to][0], d[to][1] + 1, d[to][2] + 1, d[to][st[v]]});
      |                                                                                ^
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][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: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][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: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][1]});
      |                                                                            ^
catdog.cpp:28:76: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   28 |             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:28:76: note:   candidate expects 2 arguments, 1 provided
   28 |             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:28:76: note:   candidate expects 3 arguments, 1 provided
   28 |             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:41:43: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   41 |     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:41:43: note:   candidate expects 2 arguments, 1 provided
   41 |     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:41:43: note:   candidate expects 3 arguments, 1 provided
   41 |     return min({d[0][0], d[0][1], d[0][2]});
      |                                           ^