#include "Anna.h"
#include <cstring>
#include <vector>
using namespace std;
namespace A {
const int N = 1000000, K = 100, INF = 0x3f3f3f3f;
int aa[N], ii[N], n, l, r, h;
}
using namespace A;
void InitA(int N, int L, int R) {
n = N, l = L, r = R;
for (h = 0; h < 7; h++)
SendA(l / K >> h);
for (h = 0; h < 7; h++)
SendA(r / K >> h);
memset(aa, 0, n * sizeof *aa), memset(ii, 0, n * sizeof *ii), n = 0, h = 0;
}
void ReceiveA(bool x) {
if (x) {
if (h < 14)
aa[n] |= 1 << h;
else
ii[n] |= 1 << h - 14;
}
if (++h == 28)
n++, h = 0;
}
int Answer() {
int a_ = INF, i_ = -1;
for (int i = 0; i < n; i++)
if (l <= ii[i] && ii[i] <= r && a_ > aa[i])
a_ = aa[i], i_ = ii[i];
return i_;
}
#include "Bruno.h"
#include <vector>
using namespace std;
namespace B {
const int N = 1000000, K = 100, INF = 0x3f3f3f3f;
int aa[N], n, l, r, h;
}
using namespace B;
typedef vector<int> vi;
void InitB(int N, vi pp) {
n = N;
for (int i = 0; i < n; i++)
aa[i] = pp[i];
l = r = h = 0;
}
void ReceiveB(bool y) {
if (y) {
if (h < 7)
l |= 1 << h;
else
r |= 1 << h - 7;
}
if (++h == 14) {
if (l == r) {
for (int i = l * K; i < n && i < (l + 1) * K; i++) {
for (int h = 0; h < 14; h++)
SendB(aa[i] >> h & 1);
for (int h = 0; h < 14; h++)
SendB(i >> h & 1);
}
} else {
for (int i = l * K; i < n && i < (l + 1) * K; i++) {
for (int h = 0; h < 14; h++)
SendB(aa[i] >> h & 1);
for (int h = 0; h < 14; h++)
SendB(i >> h & 1);
}
int i_ = -1;
for (int i = (l + 1) * K; i < n && i < r * K; i++)
if (i_ == -1 || aa[i_] > aa[i])
i_ = i;
for (int h = 0; h < 14; h++)
SendB(aa[i_] >> h & 1);
for (int h = 0; h < 14; h++)
SendB(i_ >> h & 1);
for (int i = r * K; i < n && i < (r + 1) * K; i++) {
for (int h = 0; h < 14; h++)
SendB(aa[i] >> h & 1);
for (int h = 0; h < 14; h++)
SendB(i >> h & 1);
}
}
}
}
Compilation message
Anna.cpp: In function 'void ReceiveA(bool)':
Anna.cpp:28:20: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
28 | ii[n] |= 1 << h - 14;
| ~~^~~~
Bruno.cpp: In function 'void ReceiveB(bool)':
Bruno.cpp:27:16: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
27 | r |= 1 << h - 7;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
400 KB |
Output is correct |
2 |
Correct |
2 ms |
400 KB |
Output is correct |
3 |
Correct |
2 ms |
400 KB |
Output is correct |
4 |
Correct |
1 ms |
400 KB |
Output is correct |
5 |
Correct |
1 ms |
400 KB |
Output is correct |
6 |
Incorrect |
21 ms |
200 KB |
Wrong Answer [2] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
400 KB |
Output is correct |
2 |
Correct |
2 ms |
400 KB |
Output is correct |
3 |
Correct |
2 ms |
400 KB |
Output is correct |
4 |
Correct |
1 ms |
400 KB |
Output is correct |
5 |
Correct |
1 ms |
400 KB |
Output is correct |
6 |
Incorrect |
21 ms |
200 KB |
Wrong Answer [2] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
7948 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |