제출 #1185589

#제출 시각아이디문제언어결과실행 시간메모리
1185589GoBananas69Bosses (BOI16_bosses)C++20
컴파일 에러
0 ms0 KiB
#include <algorithm> #include <cstring> #include <iostream> #include <queue> #include <vector> using namespace std; const long long MOD = 1000000007; const int maxn = 505; const int Lg = 23; const long long inf = 1000000000; typedef long long ll; typedef pair<ll, ll> pair<int, int>; vector<ll> g[maxn], c[maxn]; bool use[maxn]; ll cu = 0; ll dfs(int v, int p = -1) { ll x = 0; for (int to : c[v]) { if (to == p) continue; x += dfs(to, v); } cu += x + 1; return x + 1; } void solve() { int n; cin >> n; pair<int, int> mb = {-inf, -inf}; for (int i = 1; i <= n; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int p; cin >> p; g[p].push_back(i); mb = max(mb, make_pair((ll)g[p].size(), (ll)p)); } } ll ans = inf; for (int i = 1; i <= n; i++) { if (g[i].empty()) continue; if (abs((int)g[i].size() - (int)mb.first) > 1) continue; for (int j = 1; j <= n; j++) c[j].clear(); queue<int> q; q.push(i); memset(use, 0, sizeof(use)); use[i] = true; int h = 1; while (!q.empty()) { int v = q.front(); q.pop(); for (auto to : g[v]) { if (use[to]) continue; c[v].push_back(to); q.push(to); use[to] = true; h++; } } if (h == n) { cu = 0; dfs(i); ans = min(ans, cu); } } cout << ans << "\n"; } int main() { cin.tie(0) -> sync_with_stdio(0); int tt = 1; while (tt--) { solve(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

bosses.cpp:15:36: error: invalid declarator before ';' token
   15 | typedef pair<ll, ll> pair<int, int>;
      |                                    ^
bosses.cpp: In function 'void solve()':
bosses.cpp:43:21: error: no matching function for call to 'max(std::pair<int, int>&, std::pair<long long int, long long int>)'
   43 |             mb = max(mb, make_pair((ll)g[p].size(), (ll)p));
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:61,
                 from bosses.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
bosses.cpp:43:21: note:   deduced conflicting types for parameter 'const _Tp' ('std::pair<int, int>' and 'std::pair<long long int, long long int>')
   43 |             mb = max(mb, make_pair((ll)g[p].size(), (ll)p));
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:61,
                 from bosses.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
bosses.cpp:43:21: note:   deduced conflicting types for parameter 'const _Tp' ('std::pair<int, int>' and 'std::pair<long long int, long long int>')
   43 |             mb = max(mb, make_pair((ll)g[p].size(), (ll)p));
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from bosses.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
bosses.cpp:43:21: note:   'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
   43 |             mb = max(mb, make_pair((ll)g[p].size(), (ll)p));
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from bosses.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
bosses.cpp:43:21: note:   'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
   43 |             mb = max(mb, make_pair((ll)g[p].size(), (ll)p));
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~