Submission #1032475

# Submission time Handle Problem Language Result Execution time Memory
1032475 2024-07-23T20:23:59 Z aymanrs Chameleon's Love (JOI20_chameleon) C++14
Compilation error
0 ms 0 KB
#include "chameleon.h"
#include <bits/stdc++.h>
using namespace std;

char samecol(int i, vector<int> g[], int j){
  if(i==j) return 1;
  for(int k : g[i]){
    int r = samecol(k, g, j);
    if(r) return -r;
  }
  return 0;
}
void Solve(int N) {
  random_device rd;
  mt19937 rng(rd);
  bool v[2*N+1] = {false};
  int d[2*N+1] = {0};
  vector<int> g[2*N+1];
  auto adde = [&g](int a, int b) -> void {
    g[a].push_back(b);
    g[b].push_back(a);
  };
  for(int i = 1;i <= N;i++){
    int l = N+1, r = 2*N, m;
    while(l<r){
      m = l+r>>1;
      vector<int> s;for(int j = l;j <= m;j++) s.push_back(j);
      int te = Query(s);
      s.push_back(i);
      if(Query(s) == te){
        r = m;
      } else l=m+1;
    }
    Answer(i,l);
  }
}

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:15:17: error: no matching function for call to 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::mersenne_twister_engine(std::random_device&)'
   15 |   mt19937 rng(rd);
      |                 ^
In file included from /usr/include/c++/10/random:49,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:108,
                 from chameleon.cpp:2:
/usr/include/c++/10/bits/random.h:532:9: note: candidate: 'template<class _Sseq, class> std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mersenne_twister_engine(_Sseq&) [with _Sseq = _Sseq; <template-parameter-2-2> = <template-parameter-1-2>; _UIntType = long unsigned int; long unsigned int __w = 32; long unsigned int __n = 624; long unsigned int __m = 397; long unsigned int __r = 31; _UIntType __a = 2567483615; long unsigned int __u = 11; _UIntType __d = 4294967295; long unsigned int __s = 7; _UIntType __b = 2636928640; long unsigned int __t = 15; _UIntType __c = 4022730752; long unsigned int __l = 18; _UIntType __f = 1812433253]'
  532 |         mersenne_twister_engine(_Sseq& __q)
      |         ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/random.h:532:9: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/random.h: In substitution of 'template<class _UIntType, long unsigned int __w, long unsigned int __n, long unsigned int __m, long unsigned int __r, _UIntType __a, long unsigned int __u, _UIntType __d, long unsigned int __s, _UIntType __b, long unsigned int __t, _UIntType __c, long unsigned int __l, _UIntType __f> template<class _Sseq> using _If_seed_seq = typename std::enable_if<std::__detail::__is_seed_seq<_Sseq, std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>, _UIntType>::value>::type [with _Sseq = std::random_device; _UIntType = long unsigned int; long unsigned int __w = 32; long unsigned int __n = 624; long unsigned int __m = 397; long unsigned int __r = 31; _UIntType __a = 2567483615; long unsigned int __u = 11; _UIntType __d = 4294967295; long unsigned int __s = 7; _UIntType __b = 2636928640; long unsigned int __t = 15; _UIntType __c = 4022730752; long unsigned int __l = 18; _UIntType __f = 1812433253]':
/usr/include/c++/10/bits/random.h:530:32:   required from here
/usr/include/c++/10/bits/random.h:493:8: error: 'class std::random_device' has no member named 'generate'
  493 |  using _If_seed_seq = typename enable_if<__detail::__is_seed_seq<
      |        ^~~~~~~~~~~~
/usr/include/c++/10/bits/random.h:521:7: note: candidate: 'std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mersenne_twister_engine(std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type) [with _UIntType = long unsigned int; long unsigned int __w = 32; long unsigned int __n = 624; long unsigned int __m = 397; long unsigned int __r = 31; _UIntType __a = 2567483615; long unsigned int __u = 11; _UIntType __d = 4294967295; long unsigned int __s = 7; _UIntType __b = 2636928640; long unsigned int __t = 15; _UIntType __c = 4022730752; long unsigned int __l = 18; _UIntType __f = 1812433253; std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type = long unsigned int]'
  521 |       mersenne_twister_engine(result_type __sd)
      |       ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/random.h:521:43: note:   no known conversion for argument 1 from 'std::random_device' to 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::result_type' {aka 'long unsigned int'}
  521 |       mersenne_twister_engine(result_type __sd)
      |                               ~~~~~~~~~~~~^~~~
/usr/include/c++/10/bits/random.h:518:7: note: candidate: 'std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mersenne_twister_engine() [with _UIntType = long unsigned int; long unsigned int __w = 32; long unsigned int __n = 624; long unsigned int __m = 397; long unsigned int __r = 31; _UIntType __a = 2567483615; long unsigned int __u = 11; _UIntType __d = 4294967295; long unsigned int __s = 7; _UIntType __b = 2636928640; long unsigned int __t = 15; _UIntType __c = 4022730752; long unsigned int __l = 18; _UIntType __f = 1812433253]'
  518 |       mersenne_twister_engine() : mersenne_twister_engine(default_seed) { }
      |       ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/random.h:518:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/10/bits/random.h:463:11: note: candidate: 'constexpr std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::mersenne_twister_engine(const std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>&)'
  463 |     class mersenne_twister_engine
      |           ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/random.h:463:11: note:   no known conversion for argument 1 from 'std::random_device' to 'const std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>&'
/usr/include/c++/10/bits/random.h:463:11: note: candidate: 'constexpr std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>::mersenne_twister_engine(std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>&&)'
/usr/include/c++/10/bits/random.h:463:11: note:   no known conversion for argument 1 from 'std::random_device' to 'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>&&'
chameleon.cpp:26:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |       m = l+r>>1;
      |           ~^~
chameleon.cpp:15:11: warning: unused variable 'rng' [-Wunused-variable]
   15 |   mt19937 rng(rd);
      |           ^~~
chameleon.cpp:16:8: warning: unused variable 'v' [-Wunused-variable]
   16 |   bool v[2*N+1] = {false};
      |        ^
chameleon.cpp:17:7: warning: unused variable 'd' [-Wunused-variable]
   17 |   int d[2*N+1] = {0};
      |       ^