Submission #666874

#TimeUsernameProblemLanguageResultExecution timeMemory
666874Hacv16Ball Machine (BOI13_ballmachine)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int MAX = 450; const int INF = 0x3f3f3f3f; int n, q, fill[MAX], add, root, ans; vector<int> adj[MAX]; void dfs(int u, int p){ for(auto v : adj[u]){ if(v == p) continue; if(!fill[v]) dfs(v, u); } if(add && !fill[u]) fill[u] = true, ans = u, add--; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> q; for(int i = 1; i <= n; i++){ int x; cin >> x; if(x != 0){ adj[x].push_back(i); adj[i].push_back(x); }else{ root = i; } } for(int i = 1; i <= n; i++) sort(adj[i].begin(), adj[i].end()); while(q--){ int op, k; cin >> op >> k; if(op == 1){ add = k; ans = root; dfs(root); cout << ans << '\n'; }else{ cout << rand() << '\n'; } } return 0; }

Compilation message (stderr)

ballmachine.cpp: In function 'void dfs(int, int)':
ballmachine.cpp:15:13: error: reference to 'fill' is ambiguous
   15 |         if(!fill[v]) dfs(v, u);
      |             ^~~~
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ballmachine.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:191:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
In file included from /usr/include/c++/10/vector:68,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ballmachine.cpp:1:
/usr/include/c++/10/bits/stl_bvector.h:434:3: note:                 'void std::fill(std::_Bit_iterator, std::_Bit_iterator, const bool&)'
  434 |   fill(_Bit_iterator __first, _Bit_iterator __last, const bool& __x)
      |   ^~~~
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from ballmachine.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:937:5: note:                 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)'
  937 |     fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
      |     ^~~~
ballmachine.cpp:9:11: note:                 'int fill [450]'
    9 | int n, q, fill[MAX], add, root, ans;
      |           ^~~~
ballmachine.cpp:18:16: error: reference to 'fill' is ambiguous
   18 |     if(add && !fill[u]) fill[u] = true, ans = u, add--;
      |                ^~~~
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ballmachine.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:191:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
In file included from /usr/include/c++/10/vector:68,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ballmachine.cpp:1:
/usr/include/c++/10/bits/stl_bvector.h:434:3: note:                 'void std::fill(std::_Bit_iterator, std::_Bit_iterator, const bool&)'
  434 |   fill(_Bit_iterator __first, _Bit_iterator __last, const bool& __x)
      |   ^~~~
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from ballmachine.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:937:5: note:                 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)'
  937 |     fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
      |     ^~~~
ballmachine.cpp:9:11: note:                 'int fill [450]'
    9 | int n, q, fill[MAX], add, root, ans;
      |           ^~~~
ballmachine.cpp:18:25: error: reference to 'fill' is ambiguous
   18 |     if(add && !fill[u]) fill[u] = true, ans = u, add--;
      |                         ^~~~
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ballmachine.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:191:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
In file included from /usr/include/c++/10/vector:68,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from ballmachine.cpp:1:
/usr/include/c++/10/bits/stl_bvector.h:434:3: note:                 'void std::fill(std::_Bit_iterator, std::_Bit_iterator, const bool&)'
  434 |   fill(_Bit_iterator __first, _Bit_iterator __last, const bool& __x)
      |   ^~~~
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from ballmachine.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:937:5: note:                 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)'
  937 |     fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
      |     ^~~~
ballmachine.cpp:9:11: note:                 'int fill [450]'
    9 | int n, q, fill[MAX], add, root, ans;
      |           ^~~~
ballmachine.cpp: In function 'int main()':
ballmachine.cpp:48:21: error: too few arguments to function 'void dfs(int, int)'
   48 |             dfs(root);
      |                     ^
ballmachine.cpp:12:6: note: declared here
   12 | void dfs(int u, int p){
      |      ^~~