# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1025990 |
2024-07-17T12:18:14 Z |
AdamGS |
Shopping (JOI21_shopping) |
C++17 |
|
354 ms |
58344 KB |
#include "Anna.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
namespace {
int n, l, r, ile;
vector<int>pos;
vector<bool>bits;
void check() {
++ile;
int a=0, b=0;
rep(i, 20) if(bits[i]) a|=1<<i;
rep(i, 20) if(bits[i+20]) b|=1<<i;
vector<int>tmp;
bool zawiera=true;
rep(i, pos.size()) if((i<a || i>b) && (l<=pos[i] && pos[i]<=r)) zawiera=false;
if(zawiera) {
SendA(1);
rep(i, pos.size()) if(pos[a]<=pos[i] && pos[i]<=pos[b]) tmp.pb(pos[i]);
} else {
SendA(0);
rep(i, pos.size()) if(pos[a]>pos[i] || pos[i]>pos[b]) tmp.pb(pos[i]);
}
pos=tmp;
bits.clear();
}
}
void InitA(int _N, int _L, int _R) {
n=_N; l=_L; r=_R;
ile=0;
pos.clear();
bits.clear();
rep(i, n) pos.pb(i);
}
void ReceiveA(bool x) {
bits.pb(x);
if(bits.size()==40 && ile<18) check();
}
int Answer() {
vector<int>T;
rep(i, pos.size()) {
int x=0;
rep(j, 20) if(bits[i*20+j]) x|=1<<j;
T.pb(x);
}
pair<int,int>mi={n, n};
rep(i, pos.size()) if(l<=pos[i] && pos[i]<=r) mi=min(mi, {T[i], pos[i]});
return mi.nd;
}
#include "Bruno.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
namespace {
const int LIM=1e6+7;
int lewo[LIM], prawo[LIM], odw[LIM], n, ile;
pair<int,int>xd;
vector<int>T, pos;
void send() {
int m=pos.size();
vector<pair<int,int>>P, S;
rep(i, m) {
lewo[i]=prawo[i]=i;
odw[i]=0;
P.pb({T[pos[i]], i});
}
sort(all(P));
reverse(all(P));
for(auto i : P) {
int l=i.nd, r=i.nd;
if(l && odw[l-1]) {
lewo[r]=lewo[l-1];
prawo[lewo[r]]=r;
l=lewo[r];
}
if(r<m-1 && odw[r+1]) {
prawo[l]=prawo[r+1];
lewo[prawo[l]]=l;
r=prawo[l];
}
odw[i.nd]=1;
S.pb({l, r});
}
pair<int,int>mi={LIM, LIM};
rep(i, m) {
int d=S[i].nd-S[i].st+1;
mi=min(mi, {max(d, (int)pos.size()-d), i});
}
xd=S[mi.nd];
rep(i, 20) if(S[mi.nd].st&(1<<i)) SendB(1); else SendB(0);
rep(i, 20) if(S[mi.nd].nd&(1<<i)) SendB(1); else SendB(0);
}
}
void InitB(int _N, vector<int>_T) {
n=_N; ile=0;
T=_T;
pos.clear();
rep(i, n) pos.pb(i);
send();
}
void ReceiveB(bool y) {
++ile;
vector<int>tmp;
if(y) {
rep(i, pos.size()) if(xd.st<=i && i<=xd.nd) tmp.pb(pos[i]);
} else {
rep(i, pos.size()) if(xd.st>i || i>xd.nd) tmp.pb(pos[i]);
}
pos=tmp;
if(ile<18) {
send();
return;
}
rep(i, pos.size()) {
rep(j, 20) if(T[pos[i]]&(1<<j)) SendB(1); else SendB(0);
}
}
Compilation message
Anna.cpp: In function 'void {anonymous}::check()':
Anna.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
| ^
Anna.cpp:20:5: note: in expansion of macro 'rep'
20 | rep(i, pos.size()) if((i<a || i>b) && (l<=pos[i] && pos[i]<=r)) zawiera=false;
| ^~~
Anna.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
| ^
Anna.cpp:23:7: note: in expansion of macro 'rep'
23 | rep(i, pos.size()) if(pos[a]<=pos[i] && pos[i]<=pos[b]) tmp.pb(pos[i]);
| ^~~
Anna.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
| ^
Anna.cpp:26:7: note: in expansion of macro 'rep'
26 | rep(i, pos.size()) if(pos[a]>pos[i] || pos[i]>pos[b]) tmp.pb(pos[i]);
| ^~~
Anna.cpp: In function 'int Answer()':
Anna.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
| ^
Anna.cpp:45:3: note: in expansion of macro 'rep'
45 | rep(i, pos.size()) {
| ^~~
Anna.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
| ^
Anna.cpp:51:3: note: in expansion of macro 'rep'
51 | rep(i, pos.size()) if(l<=pos[i] && pos[i]<=r) mi=min(mi, {T[i], pos[i]});
| ^~~
Bruno.cpp: In function 'void ReceiveB(bool)':
Bruno.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
| ^
Bruno.cpp:60:5: note: in expansion of macro 'rep'
60 | rep(i, pos.size()) if(xd.st<=i && i<=xd.nd) tmp.pb(pos[i]);
| ^~~
Bruno.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
| ^
Bruno.cpp:62:5: note: in expansion of macro 'rep'
62 | rep(i, pos.size()) if(xd.st>i || i>xd.nd) tmp.pb(pos[i]);
| ^~~
Bruno.cpp:4:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(a, b) for(int a = 0; a < (b); ++a)
| ^
Bruno.cpp:69:3: note: in expansion of macro 'rep'
69 | rep(i, pos.size()) {
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
668 KB |
Output is correct |
2 |
Correct |
6 ms |
664 KB |
Output is correct |
3 |
Correct |
6 ms |
664 KB |
Output is correct |
4 |
Correct |
5 ms |
664 KB |
Output is correct |
5 |
Correct |
5 ms |
664 KB |
Output is correct |
6 |
Correct |
4 ms |
916 KB |
Output is correct |
7 |
Correct |
5 ms |
664 KB |
Output is correct |
8 |
Correct |
3 ms |
664 KB |
Output is correct |
9 |
Correct |
5 ms |
664 KB |
Output is correct |
10 |
Correct |
4 ms |
920 KB |
Output is correct |
11 |
Correct |
4 ms |
664 KB |
Output is correct |
12 |
Correct |
5 ms |
668 KB |
Output is correct |
13 |
Correct |
3 ms |
664 KB |
Output is correct |
14 |
Correct |
5 ms |
828 KB |
Output is correct |
15 |
Correct |
4 ms |
664 KB |
Output is correct |
16 |
Correct |
5 ms |
920 KB |
Output is correct |
17 |
Correct |
4 ms |
664 KB |
Output is correct |
18 |
Correct |
4 ms |
916 KB |
Output is correct |
19 |
Correct |
4 ms |
664 KB |
Output is correct |
20 |
Correct |
3 ms |
664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
668 KB |
Output is correct |
2 |
Correct |
6 ms |
664 KB |
Output is correct |
3 |
Correct |
6 ms |
664 KB |
Output is correct |
4 |
Correct |
5 ms |
664 KB |
Output is correct |
5 |
Correct |
5 ms |
664 KB |
Output is correct |
6 |
Correct |
4 ms |
916 KB |
Output is correct |
7 |
Correct |
5 ms |
664 KB |
Output is correct |
8 |
Correct |
3 ms |
664 KB |
Output is correct |
9 |
Correct |
5 ms |
664 KB |
Output is correct |
10 |
Correct |
4 ms |
920 KB |
Output is correct |
11 |
Correct |
4 ms |
664 KB |
Output is correct |
12 |
Correct |
5 ms |
668 KB |
Output is correct |
13 |
Correct |
3 ms |
664 KB |
Output is correct |
14 |
Correct |
5 ms |
828 KB |
Output is correct |
15 |
Correct |
4 ms |
664 KB |
Output is correct |
16 |
Correct |
5 ms |
920 KB |
Output is correct |
17 |
Correct |
4 ms |
664 KB |
Output is correct |
18 |
Correct |
4 ms |
916 KB |
Output is correct |
19 |
Correct |
4 ms |
664 KB |
Output is correct |
20 |
Correct |
3 ms |
664 KB |
Output is correct |
21 |
Correct |
7 ms |
1432 KB |
Output is correct |
22 |
Correct |
5 ms |
1176 KB |
Output is correct |
23 |
Correct |
7 ms |
1176 KB |
Output is correct |
24 |
Correct |
7 ms |
1472 KB |
Output is correct |
25 |
Correct |
9 ms |
1176 KB |
Output is correct |
26 |
Correct |
8 ms |
1404 KB |
Output is correct |
27 |
Correct |
7 ms |
1424 KB |
Output is correct |
28 |
Correct |
6 ms |
1180 KB |
Output is correct |
29 |
Correct |
7 ms |
1396 KB |
Output is correct |
30 |
Correct |
7 ms |
1184 KB |
Output is correct |
31 |
Correct |
6 ms |
1180 KB |
Output is correct |
32 |
Correct |
7 ms |
1184 KB |
Output is correct |
33 |
Correct |
7 ms |
1416 KB |
Output is correct |
34 |
Correct |
7 ms |
1180 KB |
Output is correct |
35 |
Correct |
6 ms |
1436 KB |
Output is correct |
36 |
Correct |
8 ms |
1540 KB |
Output is correct |
37 |
Correct |
8 ms |
1416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
328 ms |
57704 KB |
Output is correct |
2 |
Correct |
298 ms |
55828 KB |
Output is correct |
3 |
Correct |
291 ms |
55608 KB |
Output is correct |
4 |
Correct |
333 ms |
58188 KB |
Output is correct |
5 |
Correct |
169 ms |
56056 KB |
Output is correct |
6 |
Correct |
196 ms |
56260 KB |
Output is correct |
7 |
Correct |
329 ms |
58252 KB |
Output is correct |
8 |
Correct |
320 ms |
56228 KB |
Output is correct |
9 |
Correct |
268 ms |
58176 KB |
Output is correct |
10 |
Correct |
258 ms |
58172 KB |
Output is correct |
11 |
Correct |
240 ms |
55620 KB |
Output is correct |
12 |
Correct |
335 ms |
58088 KB |
Output is correct |
13 |
Correct |
276 ms |
58344 KB |
Output is correct |
14 |
Correct |
217 ms |
56120 KB |
Output is correct |
15 |
Correct |
214 ms |
56028 KB |
Output is correct |
16 |
Correct |
283 ms |
56028 KB |
Output is correct |
17 |
Correct |
290 ms |
56032 KB |
Output is correct |
18 |
Correct |
308 ms |
55832 KB |
Output is correct |
19 |
Correct |
282 ms |
55668 KB |
Output is correct |
20 |
Correct |
305 ms |
56364 KB |
Output is correct |
21 |
Correct |
354 ms |
55776 KB |
Output is correct |
22 |
Correct |
320 ms |
58252 KB |
Output is correct |
23 |
Correct |
325 ms |
58252 KB |
Output is correct |
24 |
Correct |
288 ms |
55876 KB |
Output is correct |
25 |
Correct |
325 ms |
55936 KB |
Output is correct |
26 |
Correct |
314 ms |
56136 KB |
Output is correct |
27 |
Correct |
342 ms |
55884 KB |
Output is correct |
28 |
Correct |
316 ms |
56032 KB |
Output is correct |
29 |
Correct |
324 ms |
58308 KB |
Output is correct |
30 |
Correct |
221 ms |
56124 KB |
Output is correct |