Submission #764345

# Submission time Handle Problem Language Result Execution time Memory
764345 2023-06-23T10:49:42 Z Dan4Life Minerals (JOI19_minerals) C++17
Compilation error
0 ms 0 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
int n;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int cur, pre;
bool Q(int i){ cur = Query(i); bool ok=(cur!=pre); pre=cur; return ok;}
 
void dnc(vector<int> l, vector<int> r, bool d){
    int n = sz(l); int m = max(1,n*0.4); if(n<1) return;
    if(n==1) return void(Answer(l[0],r[0])); 
    if(!d) m=n-m;
    vector<int> v[2], w[2]; 
    for(int i : {0,1}) v[i].clear(), w[i].clear();
    for(int i = (d?0:m); i < (d?m:n); i++) Q(l[i]);
    for(int i = 0; i < n; i++) v[i>=m].pb(l[i]);
    shuffle(all(r),rng);
    for(int i : r){
      if(sz(w[0])==m) w[1].pb(i);
      else if(sz(w[1])==n-m) w[0].pb(i);
      else w[Q(i)].pb(i);
    }
    dnc(v[0],w[0],0); dnc(v[1],w[1],1);
}
 
void Solve(int N) {
    vector<int> w[2];
    for(int i = 1; i <= 2*N; i++) w[Q(i)].pb(i);
    dnc(w[0],w[1],0);
}

Compilation message

minerals.cpp: In function 'void dnc(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:14:39: error: no matching function for call to 'max(int, double)'
   14 |     int n = sz(l); int m = max(1,n*0.4); if(n<1) return;
      |                                       ^
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 minerals.cpp:2:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
minerals.cpp:14:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   14 |     int n = sz(l); int m = max(1,n*0.4); if(n<1) return;
      |                                       ^
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 minerals.cpp:2:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
minerals.cpp:14:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   14 |     int n = sz(l); int m = max(1,n*0.4); if(n<1) return;
      |                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from minerals.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
minerals.cpp:14:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   14 |     int n = sz(l); int m = max(1,n*0.4); if(n<1) return;
      |                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from minerals.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
minerals.cpp:14:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   14 |     int n = sz(l); int m = max(1,n*0.4); if(n<1) return;
      |                                       ^