#include "Anna.h"
#include <iostream>
#include <vector>
using namespace std;
namespace {
int n, l, r, k, cnt, ans, idx, a[1000001];
void send(int x) {
for (int i = 0; i < 9; i++) SendA((x >> i) & 1);
}
} // namespace
void InitA(int N, int L, int R) {
n = N;
l = L;
r = R;
idx = cnt = 0;
}
void find() {
int mn = l;
for (int i = l; i <= r; i++) {
if (a[i] < a[mn]) mn = i;
}
ans = mn;
}
void ReceiveA(bool x) {
if (cnt >= 10) {
cnt = 0;
idx++;
}
a[idx] |= x << cnt;
cnt++;
//if (count == 10) printf("%d ", a[idx]);
if (idx == n - 1 && cnt == 10) {
find();
}
}
int Answer() {
return ans;
}
#include "Bruno.h"
#include <vector>
using namespace std;
namespace {
int n, a[1000000], cnt, l, r, k;
bool stillF = true;
} // namespace
void send(int x) {
for (int i = 0; i < 10; i++) SendB((x >> i) & 1);
}
void InitB(int N, std::vector<int> P) {
n = N;
for(int i = 0; i < N; i++) {
a[i] = P[i];
send(a[i]);
}
cnt = 0;
k = 1;
}
void solve() {
if (l == r) send(0);
else {
int mn = 0;
for (int i = (l + 1) * k; i < r * k; i++) {
if (a[i] < a[mn]) mn = i;
}
send(mn);
}
}
void ReceiveB(bool y) {
if (cnt < 9 && stillF) {
l |= y << cnt;
cnt++;
} else if (cnt < 9) {
r |= y << cnt;
cnt++;
if (cnt == 9) {
solve();
}
} else {
cnt = 0;
stillF = false;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |