Submission #1020125

#TimeUsernameProblemLanguageResultExecution timeMemory
1020125BaytoroMinerals (JOI19_minerals)C++17
Compilation error
0 ms0 KiB
#include <cstdio> #include <vector> #include <assert.h> #include <iostream> #include <algorithm> #include <cmath> #define pb push_back using namespace std; //--------------------------------------------------------------------// // Do not change this part of the code /*#ifdef ONLINE_JUDGE int Query(int x) { cout << "q " << x << endl; fflush(stdout); int res; fflush(stdin); cin >> res; return res; } void Answer(int a, int b) { cout << "a " << a << " " << b << endl; fflush(stdout); } #else*/ // But this part can be changed #include "minerals.h" #include "grader.cpp" int Query(int x) { return query(x); } void Answer(int a, int b) { return answer(a, b); } //#endif //--------------------------------------------------------------------// vector<int> used(1e5+5); int pre=0; void calc(vector<int> a, vector<int> b, int col){ if(a.size()==0) return; if(a.size()==1){ if(used[a[0]]) return; Answer(a[0],b[0]); used[a[0]]=used[b[0]]=1; return; } int k=(0.381*a.size()); vector<int> f,A,s,B; for(int i=0;i<=k;i++) { f.pb(a[i]); pre=Query(a[i]); } for(int i=k+1;i<a.size();i++) s.pb(a[i]); for(int i=0;i<b.size();i++){ if(f.size()==A.size()){ B.pb(b[i]); continue; } else if(s.size()==B.size()){ A.pb(b[i]); continue; } int tmp=Query(b[i]); if((tmp!=pre)==col) A.pb(b[i]); else B.pb(b[i]); pre=tmp; } calc(f,A,col^1); calc(s,B,col); } void Solve(int n) { vector<int> a(2*n+1); int last=0; vector<int> f,s; for(int i=1;i<=2*n;i++){ int t=Query(i); if(t!=last) f.pb(i); else s.pb(i); last=t; pre=t; } calc(f,s,1); } /* 4 1 5 2 6 3 4 7 8 */ //--------------------------------------------------------------------// // Do not change this part of the code /*#ifdef ONLINE_JUDGE int main() { int N; fflush(stdin); cin >> N; Solve(N); cout << "f" << endl; fflush(stdout); } #endif*/ //--------------------------------------------------------------------//

Compilation message (stderr)

In file included from minerals.cpp:24:
grader.cpp: In function 'int Query(int)':
grader.cpp:39:7: error: reference to 'count' is ambiguous
   39 |     --count[type];
      |       ^~~~~
grader.cpp:22:5: note: candidates are: 'int {anonymous}::count [86011]'
   22 | int count[2 * MAX_N + 1];
      |     ^~~~~
In file included from /usr/include/c++/10/algorithm:74,
                 from minerals.cpp:5:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:101:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from minerals.cpp:5:
/usr/include/c++/10/bits/stl_algo.h:4077:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4077 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
In file included from minerals.cpp:24:
grader.cpp:40:9: error: reference to 'count' is ambiguous
   40 |     if (count[type] == 0) {
      |         ^~~~~
grader.cpp:22:5: note: candidates are: 'int {anonymous}::count [86011]'
   22 | int count[2 * MAX_N + 1];
      |     ^~~~~
In file included from /usr/include/c++/10/algorithm:74,
                 from minerals.cpp:5:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:101:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from minerals.cpp:5:
/usr/include/c++/10/bits/stl_algo.h:4077:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4077 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
In file included from minerals.cpp:24:
grader.cpp:45:7: error: reference to 'count' is ambiguous
   45 |     ++count[type];
      |       ^~~~~
grader.cpp:22:5: note: candidates are: 'int {anonymous}::count [86011]'
   22 | int count[2 * MAX_N + 1];
      |     ^~~~~
In file included from /usr/include/c++/10/algorithm:74,
                 from minerals.cpp:5:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:101:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from minerals.cpp:5:
/usr/include/c++/10/bits/stl_algo.h:4077:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4077 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
In file included from minerals.cpp:24:
grader.cpp:46:9: error: reference to 'count' is ambiguous
   46 |     if (count[type] == 1) {
      |         ^~~~~
grader.cpp:22:5: note: candidates are: 'int {anonymous}::count [86011]'
   22 | int count[2 * MAX_N + 1];
      |     ^~~~~
In file included from /usr/include/c++/10/algorithm:74,
                 from minerals.cpp:5:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:101:1: note:                 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, typename std::iterator_traits<_II>::difference_type> std::count(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from minerals.cpp:5:
/usr/include/c++/10/bits/stl_algo.h:4077:5: note:                 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4077 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
minerals.cpp: At global scope:
minerals.cpp:25:5: error: redefinition of 'int Query(int)'
   25 | int Query(int x) {
      |     ^~~~~
In file included from minerals.cpp:24:
grader.cpp:29:5: note: 'int Query(int)' previously defined here
   29 | int Query(int x) {
      |     ^~~~~
minerals.cpp: In function 'int Query(int)':
minerals.cpp:26:12: error: 'query' was not declared in this scope; did you mean 'Query'?
   26 |     return query(x);
      |            ^~~~~
      |            Query
minerals.cpp: At global scope:
minerals.cpp:28:6: error: redefinition of 'void Answer(int, int)'
   28 | void Answer(int a, int b) {
      |      ^~~~~~
In file included from minerals.cpp:24:
grader.cpp:53:6: note: 'void Answer(int, int)' previously defined here
   53 | void Answer(int a, int b) {
      |      ^~~~~~
minerals.cpp: In function 'void Answer(int, int)':
minerals.cpp:29:23: error: '{anonymous}::answer' cannot be used as a function
   29 |     return answer(a, b);
      |                       ^
minerals.cpp: In function 'void calc(std::vector<int>, std::vector<int>, int)':
minerals.cpp:51:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |  for(int i=k+1;i<a.size();i++)
      |                ~^~~~~~~~~
minerals.cpp:53:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |  for(int i=0;i<b.size();i++){
      |              ~^~~~~~~~~
In file included from minerals.cpp:24:
grader.cpp: At global scope:
grader.cpp:22:5: warning: '{anonymous}::count' defined but not used [-Wunused-variable]
   22 | int count[2 * MAX_N + 1];
      |     ^~~~~