Submission #1221619

#TimeUsernameProblemLanguageResultExecution timeMemory
1221619Theo830트리 (IOI24_tree)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define id pair<ll,vector<ll> > #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training #include "tree.h" int n; ll leaf = 0; std::vector<int> p, w; vector<vector<int> >adj; ll l,r; ii solve(ll idx){ ii ans = {0,0}; ll sum = 0; for(auto x:adj[idx]){ ii res = solve(x); ans.S += res.S; sum += res.F; } ans.F = min(ans.F,R); if(sum == 0){ ans = {L,L}; } else if(sum > R){ ans.S += sum - R; } return ans; } void init(std::vector<int> P, std::vector<int> W) { p = P; w = W; n = (int)p.size(); adj.assign(n+5,vector<int>()); f(i,1,n){ adj[p[i]].pb(i); } f(i,0,n){ if(adj[i].size() == 0){ leaf++; } } } long long query(int L, int R){ l = L; r = R; return solve(0); }

Compilation message (stderr)

tree.cpp: In function 'ii solve(ll)':
tree.cpp:40:23: error: 'R' was not declared in this scope
   40 |     ans.F = min(ans.F,R);
      |                       ^
tree.cpp:42:16: error: 'L' was not declared in this scope
   42 |         ans = {L,L};
      |                ^
tree.cpp:42:19: error: no match for 'operator=' (operand types are 'ii' {aka 'std::pair<long long int, long long int>'} and '<brace-enclosed initializer list>')
   42 |         ans = {L,L};
      |                   ^
In file included from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from tree.cpp:1:
/usr/include/c++/11/bits/stl_pair.h:418:9: note: candidate: 'template<class _U1, class _U2> constexpr typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = long long int; _T2 = long long int]'
  418 |         operator=(const pair<_U1, _U2>& __p)
      |         ^~~~~~~~
/usr/include/c++/11/bits/stl_pair.h:418:9: note:   template argument deduction/substitution failed:
tree.cpp:42:19: note:   couldn't deduce template parameter '_U1'
   42 |         ans = {L,L};
      |                   ^
In file included from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from tree.cpp:1:
/usr/include/c++/11/bits/stl_pair.h:430:9: note: candidate: 'template<class _U1, class _U2> constexpr typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = long long int; _T2 = long long int]'
  430 |         operator=(pair<_U1, _U2>&& __p)
      |         ^~~~~~~~
/usr/include/c++/11/bits/stl_pair.h:430:9: note:   template argument deduction/substitution failed:
tree.cpp:42:19: note:   couldn't deduce template parameter '_U1'
   42 |         ans = {L,L};
      |                   ^
In file included from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from tree.cpp:1:
/usr/include/c++/11/bits/stl_pair.h:390:7: note: candidate: 'constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type) [with _T1 = long long int; _T2 = long long int; typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type = const std::pair<long long int, long long int>&]'
  390 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_pair.h:393:55: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::conditional<true, const std::pair<long long int, long long int>&, const std::__nonesuch&>::type' {aka 'const std::pair<long long int, long long int>&'}
  390 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~                  
  391 |                 __and_<is_copy_assignable<_T1>,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        
  392 |                        is_copy_assignable<_T2>>::value,
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393 |                 const pair&, const __nonesuch&>::type __p)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_pair.h:401:7: note: candidate: 'constexpr std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type) [with _T1 = long long int; _T2 = long long int; typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type = std::pair<long long int, long long int>&&]'
  401 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_pair.h:404:45: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::conditional<true, std::pair<long long int, long long int>&&, std::__nonesuch&&>::type' {aka 'std::pair<long long int, long long int>&&'}
  401 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~        
  402 |                 __and_<is_move_assignable<_T1>,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  403 |                        is_move_assignable<_T2>>::value,
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  404 |                 pair&&, __nonesuch&&>::type __p)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
tree.cpp: In function 'long long int query(int, int)':
tree.cpp:66:17: error: cannot convert 'ii' {aka 'std::pair<long long int, long long int>'} to 'long long int' in return
   66 |     return solve(0);
      |            ~~~~~^~~
      |                 |
      |                 ii {aka std::pair<long long int, long long int>}