This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Anna.h"
#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define isz(x) (int)x.size()
using namespace std;
namespace {
int N, L, R, cur;
int cnt, ans, max_bit;
} // namespace
void InitA(int N, int L, int R)
{
::N = N;
::L = L;
::R = R;
max_bit = __lg(N);
int anotherL = L;
for(int i = 0; i <= max_bit; ++i) {
SendA(anotherL & 1);
anotherL >>= 1;
}
cnt = L;
}
void ReceiveA(bool x)
{
if(x && cnt <= R)
ans = cnt;
++cnt;
}
int Answer()
{
return ans;
}
#include "Bruno.h"
#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define isz(x) (int)x.size()
using namespace std;
template<class T>
struct sparse_table_min {
int n;
vector<vector<T>> data;
sparse_table_min() {}
sparse_table_min(const vector<T> &a) : n(isz(a)), data({a}) {
for(int i = 1; (1 << i) <= n; ++i) {
data.emplace_back(n - (1 << i) + 1);
for(int j = 0; j < isz(data[i]); ++j)
data[i][j] = min(data[i - 1][j], data[i - 1][j + (1 << (i - 1))]);
}
}
void init(const vector<T> &a) {
n = isz(a), data = {{a}};
for(int i = 1; (1 << i) <= n; ++i) {
data.emplace_back(n - (1 << i) + 1);
for(int j = 0; j < isz(data[i]); ++j)
data[i][j] = min(data[i - 1][j], data[i - 1][j + (1 << (i - 1))]);
}
}
T query(int l, int r) {
int len = r - l + 1;
int lg_len = 31 - __builtin_clz(len);
return min(data[lg_len][l], data[lg_len][r - (1 << lg_len) + 1]);
}
};
namespace {
int N, max_bit;
vii variable_example;
int count, cur_bit, L;
sparse_table_min<pii> st;
bool FunctionExample(bool P)
{
return !P;
}
} // namespace
void InitB(int N, std::vector<int> P)
{
variable_example.resize(N);
::N = N, max_bit = __lg(N);
for(int i = 0; i < N; ++i)
variable_example[i] = pair{P[i], i};
st.init(variable_example);
}
void cope() {
for(int i = L; i < N; ++i)
SendB(st.query(L, i).ss == i);
}
void ReceiveB(bool y)
{
if(y) L ^= 1 << cur_bit;
++cur_bit;
if(cur_bit > max_bit)
cope();
}
Compilation message (stderr)
Anna.cpp:18:15: warning: '{anonymous}::cur' defined but not used [-Wunused-variable]
18 | int N, L, R, cur;
| ^~~
Bruno.cpp:53:10: warning: 'bool {anonymous}::FunctionExample(bool)' defined but not used [-Wunused-function]
53 | bool FunctionExample(bool P)
| ^~~~~~~~~~~~~~~
Bruno.cpp:50:9: warning: '{anonymous}::count' defined but not used [-Wunused-variable]
50 | int count, cur_bit, L;
| ^~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |