# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
415474 |
2021-06-01T06:52:08 Z |
조영욱(#7635) |
Shopping (JOI21_shopping) |
C++17 |
|
20 ms |
692 KB |
#include "Anna.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
namespace {
int N, L, R;
int l,r;
vector<int> v;
} // namespace
void InitA(int N, int L, int R) {
::N = N;
::L = L;
::R = R;
l=(L*512)/N;
r=(R*512)/N;
for(int i=0;i<9;i++) {
SendA((l>>i)&1);
}
for(int i=0;i<9;i++) {
SendA((r>>i)&1);
}
}
void ReceiveA(bool x) {
v.push_back(x);
}
int Answer() {
if (L==R) {
return L;
}
int ind=0;
int ret=1048575;
int pos=-1;
bool flag=false;
for(int i=0;i<N;i++) {
int now=(i*512)/N;
if (now==l) {
if (i>=L&&i<=R) {
int val=0;
for(int j=0;j<20;j++) {
val+=(v[ind+j]<<j);
}
if (val<ret) {
ret=val;
pos=i;
}
}
ind+=20;
}
else if (now==r) {
if (!flag) {
int ps=0;
for(int j=0;j<20;j++) {
ps+=(v[ind+j]<<j);
}
ind+=20;
int val=0;
for(int j=0;j<20;j++) {
val+=(v[ind+j]<<j);
}
flag=true;
if (val<ret) {
ret=val;
pos=ps;
}
ind+=20;
}
if (i<=R) {
int val=0;
for(int j=0;j<20;j++) {
val+=(v[ind+j]<<j);
}
if (val<ret) {
ret=val;
pos=i;
}
}
ind+=20;
}
}
return pos;
}
#include "Bruno.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
namespace {
int N;
int variable_example[1000000];
int cnt;
vector<int> vec;
int le,ri;
} // namespace
void InitB(int N, vector<int> P) {
::N = N;
vec=P;
cnt=0;
}
void ReceiveB(bool y) {
if (cnt<9) {
le+=(y<<cnt);
}
else {
ri+=(y<<(cnt-9));
}
cnt++;
int mn=1048575;
int pos=1048575;
bool flag=false;
if (cnt==18) {
for(int i=0;i<N;i++) {
int now=(i*512)/N;
if (now==le) {
for(int j=0;j<20;j++) {
SendB((vec[i]>>j)&1);
}
}
else if (now>le&&now<ri) {
if (vec[i]<mn) {
pos=i;
mn=vec[i];
}
}
else if (now==ri) {
if (!flag) {
for(int j=0;j<20;j++) {
SendB((pos>>j)&1);
}
for(int j=0;j<20;j++) {
SendB((mn>>j)&1);
}
flag=true;
}
for(int j=0;j<20;j++) {
SendB((vec[i]>>j)&1);
}
}
}
}
}
Compilation message
Bruno.cpp:9:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
9 | int variable_example[1000000];
| ^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
452 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
388 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
388 KB |
Output is correct |
9 |
Correct |
5 ms |
388 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
6 ms |
388 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
452 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
388 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
388 KB |
Output is correct |
9 |
Correct |
5 ms |
388 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
6 ms |
388 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
14 ms |
512 KB |
Output is correct |
22 |
Correct |
15 ms |
588 KB |
Output is correct |
23 |
Correct |
15 ms |
512 KB |
Output is correct |
24 |
Correct |
13 ms |
512 KB |
Output is correct |
25 |
Correct |
8 ms |
520 KB |
Output is correct |
26 |
Correct |
13 ms |
592 KB |
Output is correct |
27 |
Correct |
11 ms |
604 KB |
Output is correct |
28 |
Correct |
18 ms |
576 KB |
Output is correct |
29 |
Correct |
13 ms |
600 KB |
Output is correct |
30 |
Correct |
13 ms |
600 KB |
Output is correct |
31 |
Correct |
15 ms |
512 KB |
Output is correct |
32 |
Correct |
15 ms |
692 KB |
Output is correct |
33 |
Correct |
20 ms |
668 KB |
Output is correct |
34 |
Correct |
9 ms |
676 KB |
Output is correct |
35 |
Correct |
18 ms |
512 KB |
Output is correct |
36 |
Correct |
15 ms |
512 KB |
Output is correct |
37 |
Correct |
7 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
256 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |