Submission #470417

# Submission time Handle Problem Language Result Execution time Memory
470417 2021-09-03T17:21:15 Z Omegaman Broken Device (JOI17_broken_device) C++14
49 / 100
51 ms 2672 KB
#include "Annalib.h"
#include <math.h>
 
bool isInArr(int ArrLen, int Arr[], int val) {
	for (int i = 0; i < ArrLen; i++)
		if (Arr[i] == val) return 1;
	return 0;
}
 
void Anna(int N, long long X, int K, int P[]){
	bool d[N], F[N];
	long long x = X;
	int ones = 0;
	int zeros = 0;
	for( int i = 0; i < N; i++ ){
		if(i > 0) {
			d[i] = x % 2;
			if(x > 0) {
				if(d[i]) ones++;
				else zeros++;
			}
			x /= 2;
		}
		F[i] = !isInArr(K, P, i);
	}

	d[0] = zeros <= ones;

	bool M[N];
 
	int dh = 0;
	bool pa = 0;
	for( int i = 0; i < N; i+=3) {
		int m = 0;
		if (dh < 61) {
			const bool	d1 = d[dh + 0],
					d2 = dh < 60 ? d[dh + 1] : 0,

					f1 = F[i  + 0],
					f2 = F[i  + 1],
					f3 = F[i  + 2]; 

			int dp = d1*2+d2*1;
			int bp = !f1*4+!f2*2+!f3*1;

			m = (int[2][4][8]){
				{
					{3, 4, 4, 4, 3, 2, 0, 0},
					{5, 4, 5, 4, 2, 2, 0, 0},
					{7, 0, 1, 0, 1, 0, 1, 0},
					{6, 6, 1, 0, 1, 0, 1, 0},
				},
				{
					{3, 4, 4, 4, 3, 0, 0, 0},
					{5, 4, 5, 4, 0, 0, 0, 0},
					{7, 2, 1, 0, 1, 2, 1, 0},
					{6, 6, 1, 0, 1, 2, 1, 0},
				}
			}[d[0]&&dh>0][dp][bp];
		}

		if(m) dh++;
		if((bool[8]){0,0,0,1,0,1,1,1}[m]) {
			dh++;
		}

		M[i + 2] = m % 2; m /= 2;
		M[i + 1] = m % 2; m /= 2;
		M[i + 0] = m % 2;
	}
 
	for ( int i = 0; i < N; i++ ) {
		Set(i, (int)M[i]);
	}
}
#include "Brunolib.h"
 
long long Bruno( int N, int A[] ) {
 	int len = (N < 60 ? N : 60) +1 ;
 
	bool d[len];
	for(int i = 0; i < len; i++) d[i] = 0;
 
	int dh = 0;
 
	for(int i = 0; i < N; i+=3) {
		switch (A[i]*4 + A[i+1]*2 + A[i+2]) {
			case 0:
				break;
			case 1:
				d[dh++] = 1;
				break;
			case 2:
				d[dh++] = d[0];
				break;
			case 3:
				d[dh++] = 0;
				d[dh++] = 0;
				break;
			case 4:
				d[dh++] = 0;
				break;
			case 5:
				d[dh++] = 0;
				d[dh++] = 1;
				break;
			case 6:
				d[dh++] = 1;
				d[dh++] = 1;
				break;
			case 7:
				d[dh++] = 1;
				d[dh++] = 0;
				break;
		}
	}
 
	long long X = 0;
	long long inc = 1;
	for (int i = 1; i < len; i++) {
		X += inc * d[i];
		inc *= 2;
	}
 
	return X;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:32:7: warning: unused variable 'pa' [-Wunused-variable]
   32 |  bool pa = 0;
      |       ^~
# Verdict Execution time Memory Grader output
1 Partially correct 40 ms 2444 KB Output is partially correct - L* = 20
2 Partially correct 40 ms 2596 KB Output is partially correct - L* = 21
3 Partially correct 51 ms 2672 KB Output is partially correct - L* = 21
4 Partially correct 40 ms 2444 KB Output is partially correct - L* = 23
5 Partially correct 40 ms 2504 KB Output is partially correct - L* = 20
6 Partially correct 45 ms 2404 KB Output is partially correct - L* = 24
7 Partially correct 40 ms 2464 KB Output is partially correct - L* = 20
8 Partially correct 40 ms 2444 KB Output is partially correct - L* = 20
9 Partially correct 43 ms 2408 KB Output is partially correct - L* = 20
10 Partially correct 45 ms 2476 KB Output is partially correct - L* = 25
11 Partially correct 46 ms 2464 KB Output is partially correct - L* = 22
12 Partially correct 40 ms 2444 KB Output is partially correct - L* = 22
13 Partially correct 41 ms 2524 KB Output is partially correct - L* = 21
14 Partially correct 40 ms 2492 KB Output is partially correct - L* = 22
15 Partially correct 44 ms 2400 KB Output is partially correct - L* = 22
16 Partially correct 47 ms 2392 KB Output is partially correct - L* = 21
17 Partially correct 41 ms 2392 KB Output is partially correct - L* = 20
18 Partially correct 40 ms 2596 KB Output is partially correct - L* = 21
19 Partially correct 40 ms 2456 KB Output is partially correct - L* = 22
20 Partially correct 40 ms 2416 KB Output is partially correct - L* = 22
21 Partially correct 40 ms 2416 KB Output is partially correct - L* = 20
22 Partially correct 45 ms 2408 KB Output is partially correct - L* = 20
23 Partially correct 41 ms 2436 KB Output is partially correct - L* = 20
24 Partially correct 41 ms 2460 KB Output is partially correct - L* = 21
25 Partially correct 40 ms 2420 KB Output is partially correct - L* = 21
26 Partially correct 40 ms 2408 KB Output is partially correct - L* = 22
27 Partially correct 40 ms 2408 KB Output is partially correct - L* = 22
28 Partially correct 41 ms 2572 KB Output is partially correct - L* = 23
29 Partially correct 49 ms 2432 KB Output is partially correct - L* = 22
30 Partially correct 46 ms 2360 KB Output is partially correct - L* = 22
31 Partially correct 40 ms 2560 KB Output is partially correct - L* = 24
32 Partially correct 40 ms 2400 KB Output is partially correct - L* = 24
33 Partially correct 40 ms 2500 KB Output is partially correct - L* = 20
34 Partially correct 51 ms 2428 KB Output is partially correct - L* = 20
35 Partially correct 40 ms 2412 KB Output is partially correct - L* = 22
36 Partially correct 40 ms 2564 KB Output is partially correct - L* = 19
37 Partially correct 40 ms 2464 KB Output is partially correct - L* = 20
38 Partially correct 40 ms 2572 KB Output is partially correct - L* = 19
39 Partially correct 40 ms 2492 KB Output is partially correct - L* = 22
40 Partially correct 40 ms 2440 KB Output is partially correct - L* = 21