Submission #334904

# Submission time Handle Problem Language Result Execution time Memory
334904 2020-12-10T08:04:39 Z dolphingarlic Broken Device (JOI17_broken_device) C++14
100 / 100
48 ms 2752 KB
#include "Annalib.h"

void set(int p, int x) { for (int i = 0; i < 3; i++) Set(p + i, (x >> i) & 1); }

void Anna(int N, long long X, int K, int P[]) {
	bool B[150];
	for (int i = 0; i < N; i++) B[i] = false;
	for (int i = 0; i < K; i++) B[P[i]] = true;

	for (int i = 0, j = 0; i < N; i += 3) {
		if (j > 62 || B[i] + B[i + 1] + B[i + 2] > 1) set(i, 0);
		else if ((!B[i] && !B[i + 1] && !B[i + 2]) || (B[i + 1] && !(X & (1ll << j)))) {
			if (X & (1ll << j)) {
				if (X & (1ll << j + 1)) set(i, 7);
				else set(i, 3);
			} else {
				if (X & (1ll << j + 1)) set(i, 5);
				else set(i, 4);
			}
			j += 2;
		} else {
			if (!(X & (1ll << j))) set(i, 2);
			else if (B[i]) set(i, 6);
			else set(i, 1);
			j++;
		}
	}
}
#include "Brunolib.h"

long long Bruno(int N, int A[]) {
	long long ans = 0;
	for (int i = 0, j = 0; i < N; i += 3) {
		int hsh = A[i] + 2 * A[i + 1] + 4 * A[i + 2];
		switch (hsh) {
			case 1: case 6: ans += 1ll << j;
			case 2: j++; break;
			case 7: ans += 1ll << j;
			case 5: ans += 1ll << j + 1; j += 2; break;
			case 3: ans += 1ll << j;
			case 4: j += 2; break;
		}
	}
	return ans;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:14:23: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   14 |     if (X & (1ll << j + 1)) set(i, 7);
      |                     ~~^~~
Anna.cpp:17:23: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   17 |     if (X & (1ll << j + 1)) set(i, 5);
      |                     ~~^~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:11:28: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   11 |    case 5: ans += 1ll << j + 1; j += 2; break;
      |                          ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2712 KB Output is correct - L* = 40
2 Correct 38 ms 2620 KB Output is correct - L* = 40
3 Correct 40 ms 2492 KB Output is correct - L* = 40
4 Correct 38 ms 2492 KB Output is correct - L* = 40
5 Correct 39 ms 2620 KB Output is correct - L* = 40
6 Correct 38 ms 2492 KB Output is correct - L* = 40
7 Correct 40 ms 2620 KB Output is correct - L* = 40
8 Correct 38 ms 2620 KB Output is correct - L* = 40
9 Correct 38 ms 2712 KB Output is correct - L* = 40
10 Correct 39 ms 2752 KB Output is correct - L* = 40
11 Correct 40 ms 2732 KB Output is correct - L* = 40
12 Correct 40 ms 2492 KB Output is correct - L* = 40
13 Correct 39 ms 2752 KB Output is correct - L* = 40
14 Correct 38 ms 2492 KB Output is correct - L* = 40
15 Correct 38 ms 2748 KB Output is correct - L* = 40
16 Correct 39 ms 2712 KB Output is correct - L* = 40
17 Correct 38 ms 2492 KB Output is correct - L* = 40
18 Correct 40 ms 2492 KB Output is correct - L* = 40
19 Correct 38 ms 2720 KB Output is correct - L* = 40
20 Correct 38 ms 2720 KB Output is correct - L* = 40
21 Correct 41 ms 2620 KB Output is correct - L* = 40
22 Correct 38 ms 2492 KB Output is correct - L* = 40
23 Correct 38 ms 2492 KB Output is correct - L* = 40
24 Correct 45 ms 2620 KB Output is correct - L* = 40
25 Correct 48 ms 2620 KB Output is correct - L* = 40
26 Correct 38 ms 2492 KB Output is correct - L* = 40
27 Correct 39 ms 2620 KB Output is correct - L* = 40
28 Correct 38 ms 2720 KB Output is correct - L* = 40
29 Correct 38 ms 2492 KB Output is correct - L* = 40
30 Correct 40 ms 2492 KB Output is correct - L* = 40
31 Correct 41 ms 2712 KB Output is correct - L* = 40
32 Correct 39 ms 2712 KB Output is correct - L* = 40
33 Correct 39 ms 2492 KB Output is correct - L* = 40
34 Correct 40 ms 2712 KB Output is correct - L* = 40
35 Correct 38 ms 2492 KB Output is correct - L* = 40
36 Correct 40 ms 2492 KB Output is correct - L* = 40
37 Correct 38 ms 2492 KB Output is correct - L* = 40
38 Correct 39 ms 2620 KB Output is correct - L* = 40
39 Correct 38 ms 2492 KB Output is correct - L* = 40
40 Correct 44 ms 2492 KB Output is correct - L* = 40