답안 #1113502

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1113502 2024-11-16T16:48:07 Z epicci23 커다란 상품 (IOI17_prize) C++17
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"
#include "prize.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
 
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int rand(int l,int r){
  return l + rng() % (r-l+1);
}

int suf = -1;
vector<int> Cache={-1,-1};
map<int,vector<int>> dp;
 
vector<int> Ask(int i){
  if( dp.count(i) ) return dp[i];
  return dp[i] = ask(i);
}
 
int ask_all(int l,int r){
  for(int i = l; i <= r; i++){
    vector<int> x = Ask(i);
    if(x[0] + x[1] == 0) return i;
    if(x[1] == suf) Cache = x;
    else suf--;
  }
  return -23;
}
 
int Learn(int l,int r){
  if(l>r) return -1;
  if(l==r){
    auto u = Ask(l);
    if(u[0] + u[1] == 0) return l;
    if(u[1] == suf) Cache=u;
    else suf--;
    return -1;
  }
  auto X = Ask(r);
  if(X[0] + X[1] == 0) return r;
  if(X[1] == suf) return -1;
  int mid = rng(l , r);
  auto u = Ask(mid);
  if(u[0] + u[1] == 0) return mid;
  if(u[1] == suf) return Learn(mid + 1,r - 1);
  int lf = Learn(l,mid - 1);
  if(lf != -1) return lf;
  if(u[1]==suf) Cache=u;
  else suf--; 
  if(X[1] == suf - ( Cache[0]+Cache[1] > X[0] + X[1] ) ) return -1;
  int hm = Learn( mid + 1, r - 1 );
  if(hm !=- 1) return hm;
  if(X[1] == suf) Cache = X;
  else suf--;
  return -1;
}
 
int find_best(int n){
  if(n <= 1000) return ask_all(0, n - 1);
  int art = 0;
  for(int i = 0; i <= 500; i++){
  	if(art == 5) return Learn(i, n - 1);
    vector<int> x = Ask(i);
    if(x[0] + x[1] == 0) return i;
    if(x[0] + x[1] > Cache[0] + Cache[1]) art++;
    if(x[0] + x[1] >= Cache[0] + Cache[1]){
      Cache = x;
      suf = Cache[1];
    }
    else suf--;
  }
  return Learn(501, n - 1 );
}

Compilation message

prize.cpp: In function 'int Learn(int, int)':
prize.cpp:45:22: error: no match for call to '(std::mt19937_64 {aka std::mersenne_twister_engine<long unsigned int, 64, 312, 156, 31, 13043109905998158313, 29, 6148914691236517205, 17, 8202884508482404352, 37, 18444473444759240704, 43, 6364136223846793005>}) (int&, int&)'
   45 |   int mid = rng(l , r);
      |                      ^
In file included from /usr/include/c++/10/random:51,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:108,
                 from prize.cpp:1:
/usr/include/c++/10/bits/random.tcc:450:5: note: candidate: 'std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::operator()() [with _UIntType = long unsigned int; long unsigned int __w = 64; long unsigned int __n = 312; long unsigned int __m = 156; long unsigned int __r = 31; _UIntType __a = 13043109905998158313; long unsigned int __u = 29; _UIntType __d = 6148914691236517205; long unsigned int __s = 17; _UIntType __b = 8202884508482404352; long unsigned int __t = 37; _UIntType __c = 18444473444759240704; long unsigned int __l = 43; _UIntType __f = 6364136223846793005; std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type = long unsigned int]'
  450 |     mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d,
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  451 |        __s, __b, __t, __c, __l, __f>::
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/random.tcc:450:5: note:   candidate expects 0 arguments, 2 provided