#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 & 1);
for (h = 0; h < 7; h++)
SendA(r / K >> h & 1);
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;
if (i_ != -1) {
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;
| ~~^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
400 KB |
Output is correct |
2 |
Correct |
1 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 |
Correct |
22 ms |
400 KB |
Output is correct |
7 |
Correct |
47 ms |
400 KB |
Output is correct |
8 |
Correct |
38 ms |
400 KB |
Output is correct |
9 |
Correct |
20 ms |
420 KB |
Output is correct |
10 |
Correct |
16 ms |
400 KB |
Output is correct |
11 |
Correct |
49 ms |
400 KB |
Output is correct |
12 |
Correct |
42 ms |
400 KB |
Output is correct |
13 |
Correct |
50 ms |
400 KB |
Output is correct |
14 |
Correct |
48 ms |
400 KB |
Output is correct |
15 |
Correct |
53 ms |
400 KB |
Output is correct |
16 |
Correct |
46 ms |
508 KB |
Output is correct |
17 |
Correct |
41 ms |
400 KB |
Output is correct |
18 |
Correct |
27 ms |
400 KB |
Output is correct |
19 |
Correct |
15 ms |
400 KB |
Output is correct |
20 |
Correct |
21 ms |
400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
400 KB |
Output is correct |
2 |
Correct |
1 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 |
Correct |
22 ms |
400 KB |
Output is correct |
7 |
Correct |
47 ms |
400 KB |
Output is correct |
8 |
Correct |
38 ms |
400 KB |
Output is correct |
9 |
Correct |
20 ms |
420 KB |
Output is correct |
10 |
Correct |
16 ms |
400 KB |
Output is correct |
11 |
Correct |
49 ms |
400 KB |
Output is correct |
12 |
Correct |
42 ms |
400 KB |
Output is correct |
13 |
Correct |
50 ms |
400 KB |
Output is correct |
14 |
Correct |
48 ms |
400 KB |
Output is correct |
15 |
Correct |
53 ms |
400 KB |
Output is correct |
16 |
Correct |
46 ms |
508 KB |
Output is correct |
17 |
Correct |
41 ms |
400 KB |
Output is correct |
18 |
Correct |
27 ms |
400 KB |
Output is correct |
19 |
Correct |
15 ms |
400 KB |
Output is correct |
20 |
Correct |
21 ms |
400 KB |
Output is correct |
21 |
Correct |
54 ms |
656 KB |
Output is correct |
22 |
Correct |
40 ms |
656 KB |
Output is correct |
23 |
Correct |
44 ms |
612 KB |
Output is correct |
24 |
Correct |
43 ms |
740 KB |
Output is correct |
25 |
Correct |
27 ms |
656 KB |
Output is correct |
26 |
Correct |
46 ms |
656 KB |
Output is correct |
27 |
Correct |
38 ms |
656 KB |
Output is correct |
28 |
Correct |
46 ms |
656 KB |
Output is correct |
29 |
Correct |
46 ms |
656 KB |
Output is correct |
30 |
Correct |
58 ms |
656 KB |
Output is correct |
31 |
Correct |
38 ms |
732 KB |
Output is correct |
32 |
Correct |
38 ms |
600 KB |
Output is correct |
33 |
Correct |
52 ms |
656 KB |
Output is correct |
34 |
Correct |
56 ms |
656 KB |
Output is correct |
35 |
Correct |
47 ms |
732 KB |
Output is correct |
36 |
Correct |
28 ms |
656 KB |
Output is correct |
37 |
Correct |
16 ms |
656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
7936 KB |
Wrong Answer [1] |
2 |
Halted |
0 ms |
0 KB |
- |