Submission #396386

# Submission time Handle Problem Language Result Execution time Memory
396386 2021-04-29T22:36:09 Z ChrisT Shopping (JOI21_shopping) C++17
10 / 100
102 ms 596 KB
#include <bits/stdc++.h>
#include "Anna.h"
using namespace std;
const int MN = 1e6 + 5;
vector<int> go,mx; int ind = 0, bit = 0, L, R;
void InitA (int n, int l, int r) {
	L = l; R = r;
	int baseL = 0, baseR = 0;
	for (int i = 14; i > 5; i--) {
		SendA(l>>i&1);
		baseL |= (l & (1 << i));
	}
	for (int i = 14; i > 5; i--) {
		SendA(r>>i&1);
		baseR |= (r & (1 << i));
	}
	for (int low = 0; low < (1 << 6); low++) {
		go.push_back(baseL | low);
		go.push_back(baseR | low);
	}
	sort(go.begin(),go.end());
	go.erase(unique(go.begin(),go.end()),go.end());
	mx.resize((int)go.size()*5);
}
void ReceiveA (bool x) {
	mx[ind] |= (((int)x) << bit);
	if ((++bit) > 14) {
		bit = 0; ++ind;
	}
}
int Answer () {
	int st = -1, ret = 1e9, id = -1;
	for (int i = 0; i < (int)go.size(); i++) {
		if (go[i] == L) st = i;
	}
	for (int i = st; i < (int)go.size(); i++) {
		if (mx[4 * i] < ret) {
			ret = mx[4 * i];
			id = mx[4 * i + 1];
		}
		if (go[i] == R) break;
		if (mx[4 * i + 2] < ret) {
			ret = mx[4 * i + 2];
			id = mx[4 * i + 3];
		}
	}
	return id;
}
#include <bits/stdc++.h>
#include "Bruno.h"
using namespace std;
const int MN = 1e6 + 5;
vector<int> go,mx,p,has(2); int ind = 0, bit = 14, N;
void InitB (int n, vector<int> pp) {
	p=pp;
}
void relay (int x) {
	for (int j = 0; j <= 14; j++) SendB(x >> j & 1);
}
void ReceiveB (bool x) {
	has[ind] |= (((int)x) << bit);
	if ((--bit) < 6) {
		bit = 14; ++ind;
	}
	if (ind > 1) {
		for (int low = 0; low < (1 << 6); low++) {
			go.push_back(has[0] | low);
			go.push_back(has[1] | low);
		}
		sort(go.begin(),go.end());
		go.erase(unique(go.begin(),go.end()),go.end());
		for (int i = 0; i < (int)go.size(); i++) {
			relay(p[go[i]]); relay(go[i]);
			if (i + 1 < (int)go.size()) {
				int mx = 1e4 + 1, id = 0;
				for (int j = go[i] + 1; j < go[i+1]; j++) {
					if (p[j] < mx) {
						mx = p[j];
						id = j;
					}
				}
				relay(mx); relay(id);
			}
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 37 ms 384 KB Output is correct
2 Correct 37 ms 384 KB Output is correct
3 Correct 49 ms 384 KB Output is correct
4 Correct 43 ms 408 KB Output is correct
5 Correct 33 ms 404 KB Output is correct
6 Correct 98 ms 496 KB Output is correct
7 Correct 87 ms 388 KB Output is correct
8 Correct 36 ms 492 KB Output is correct
9 Correct 71 ms 384 KB Output is correct
10 Correct 43 ms 384 KB Output is correct
11 Correct 79 ms 384 KB Output is correct
12 Correct 67 ms 384 KB Output is correct
13 Correct 82 ms 384 KB Output is correct
14 Correct 56 ms 384 KB Output is correct
15 Correct 42 ms 384 KB Output is correct
16 Correct 79 ms 384 KB Output is correct
17 Correct 36 ms 488 KB Output is correct
18 Correct 35 ms 384 KB Output is correct
19 Correct 46 ms 384 KB Output is correct
20 Correct 48 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 384 KB Output is correct
2 Correct 37 ms 384 KB Output is correct
3 Correct 49 ms 384 KB Output is correct
4 Correct 43 ms 408 KB Output is correct
5 Correct 33 ms 404 KB Output is correct
6 Correct 98 ms 496 KB Output is correct
7 Correct 87 ms 388 KB Output is correct
8 Correct 36 ms 492 KB Output is correct
9 Correct 71 ms 384 KB Output is correct
10 Correct 43 ms 384 KB Output is correct
11 Correct 79 ms 384 KB Output is correct
12 Correct 67 ms 384 KB Output is correct
13 Correct 82 ms 384 KB Output is correct
14 Correct 56 ms 384 KB Output is correct
15 Correct 42 ms 384 KB Output is correct
16 Correct 79 ms 384 KB Output is correct
17 Correct 36 ms 488 KB Output is correct
18 Correct 35 ms 384 KB Output is correct
19 Correct 46 ms 384 KB Output is correct
20 Correct 48 ms 384 KB Output is correct
21 Correct 101 ms 512 KB Output is correct
22 Correct 62 ms 512 KB Output is correct
23 Correct 90 ms 580 KB Output is correct
24 Correct 102 ms 576 KB Output is correct
25 Correct 48 ms 584 KB Output is correct
26 Correct 80 ms 512 KB Output is correct
27 Correct 64 ms 580 KB Output is correct
28 Correct 78 ms 512 KB Output is correct
29 Correct 61 ms 584 KB Output is correct
30 Correct 70 ms 584 KB Output is correct
31 Correct 100 ms 576 KB Output is correct
32 Correct 69 ms 580 KB Output is correct
33 Correct 47 ms 512 KB Output is correct
34 Correct 77 ms 584 KB Output is correct
35 Correct 53 ms 512 KB Output is correct
36 Correct 86 ms 596 KB Output is correct
37 Correct 48 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 264 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -