Submission #951323

#TimeUsernameProblemLanguageResultExecution timeMemory
951323browntoadToxic Gene (NOI23_toxic)C++17
Compilation error
0 ms0 KiB
#include "toxic.h" #include <bits/stdc++.h> using namespace std; const int K = 8, T = 30; vector<int> encode(vector<int> qry) { int n = qry.size(); vector<int> ret; for (int i = 0; i < n; i++) { for (int j = 0; j < (1 << i); j++) { ret.push_back(qry[i]); } } return ret; } void determine_type(int n) { mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<int> ord(n); iota(ord.begin(), ord.end(), 1); string ans(n + 1, 'R'); int cnt = 0; int tt = -1; vector<int> stk; int i = 0; while (cnt < T && i < n) { // srand(mt19937(time(0))() + 864197532); random_shuffle(ord.begin(), ord.begin() + i, rng); int j = min(n, i + K); int xx = -1; { vector<int> qry; for (int k = i; k < j; k++) { qry.push_back(ord[k]); } int x = min(stk.size(), K - qry.size()); for (int k = 0; k < x; k++) { qry.push_back(stk.end()[-1 - k]); } xx = query_sample(encode(qry)); if (xx == (1 << qry.size()) - 1) { stk.insert(stk.end(), qry.begin(), qry.end()); i = j; continue; } else { for (int k = j - i; k < qry.size(); k++) { ans[qry[k]] = (xx >> k & 1) ? 'S' : 'R'; } for (int k = 0; k < x; k++) { stk.pop_back(); } } } int l = i, r = j; auto make_query = [&](int mid) { vector<int> qry; for (int k = l; k < mid; k++) { qry.push_back(ord[k]); } int x = min(stk.size(), K - qry.size()); for (int k = 0; k < x; k++) { qry.push_back(stk.end()[-1 - k]); } return qry; }; while (l < r - 1) { int mid = (l + r) / 2; vector<int> qry = make_query(mid); int res = query_sample(encode(qry)); if (res == (1 << qry.size()) - 1) { l = mid; } else { int x = qry.size() - (mid - l); for (int k = mid - l; k < qry.size(); k++) { ans[qry[k]] = (res >> k & 1) ? 'S' : 'R'; } for (int k = 0; k < x; k++) { stk.pop_back(); } r = mid; } } for (int k = 0; k < l - i; k++) { ans[ord[i + k]] = (xx >> k & 1) ? 'S' : 'R'; } ans[ord[l]] = 'T'; i = l + 1; tt = ord[l]; cnt++; } while (i < n) { stk.push_back(ord[i++]); } while (stk.size()) { int x = min((int)stk.size(), K); vector<int> qry; for (int k = 0; k < x; k++) { qry.push_back(stk.back()); stk.pop_back(); } auto tmp = encode(qry); tmp.push_back(tt); int res = query_sample(tmp); for (int k = 0; k < (int)qry.size(); k++) { ans[qry[k]] = (res >> k & 1) ? 'S' : 'R'; } } for (int j = 1; j <= n; j++) { answer_type(j, ans[j]); } }

Compilation message (stderr)

toxic.cpp: In function 'void determine_type(int)':
toxic.cpp:55:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (int k = j - i; k < qry.size(); k++)
      |                         ~~^~~~~~~~~~~~
toxic.cpp:92:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |     for (int k = mid - l; k < qry.size(); k++)
      |                           ~~^~~~~~~~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from toxic.cpp:2:
/usr/include/c++/10/bits/stl_algo.h: In instantiation of 'void std::random_shuffle(_RAIter, _RAIter, _Generator&&) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Generator = std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>&]':
toxic.cpp:32:51:   required from here
/usr/include/c++/10/bits/stl_algo.h:4636:48: error: no match for call to '(std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>) (__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
 4636 |    _RandomAccessIterator __j = __first + __rand((__i - __first) + 1);
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/random:49,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:108,
                 from toxic.cpp:2:
/usr/include/c++/10/bits/random.h:563:7: 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 = 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]'
  563 |       operator()();
      |       ^~~~~~~~
/usr/include/c++/10/bits/random.h:563:7: note:   candidate expects 0 arguments, 1 provided