Submission #470316

# Submission time Handle Problem Language Result Execution time Memory
470316 2021-09-03T13:18:12 Z Omegaman Broken Device (JOI17_broken_device) C++14
51 / 100
57 ms 2612 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;
	for( int i = 0; i < N; i++ ){
		d[i] = x % 2;
		x /= 2;
		F[i] = !isInArr(K, P, i);
	}

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

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

			int broken = !f1 + !f2 + !f3;

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

			if (broken < 2 && dh < 59) { if (0) return; else 
				if ( dp == 0 )	m = (      f2 && f3) ? 3 : 4 * f1; else 
				if ( dp == 1 )	m = (f1       && f3) ? 5 : 2 * f2; else
				if ( dp == 2 )	m = (f1 && f2 && f3) ? 7 : 1 * f3; else
				if ( dp == 3 )	m = (f1 && f2      ) ? 6 : 1 * f3;
			} else if ( broken <= 2 ) {
				if ( d1)
					if (f3) m = 1 * f3;
				if (!d1) {
					if (f2) m = 2 * f2;
					if (f1) m = 4 * f1;
				}
			}
		}

		if(m) dh++;
		if(m>4||m==3) 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);
 
	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++] = 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 = 0; 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:35:8: warning: unused variable 'bp' [-Wunused-variable]
   35 |    int bp = f1*4+f2*2+f3*1;
      |        ^~
# Verdict Execution time Memory Grader output
1 Partially correct 44 ms 2404 KB Output is partially correct - L* = 24
2 Partially correct 41 ms 2428 KB Output is partially correct - L* = 21
3 Partially correct 57 ms 2408 KB Output is partially correct - L* = 21
4 Partially correct 45 ms 2464 KB Output is partially correct - L* = 23
5 Partially correct 43 ms 2468 KB Output is partially correct - L* = 20
6 Partially correct 43 ms 2452 KB Output is partially correct - L* = 24
7 Partially correct 41 ms 2544 KB Output is partially correct - L* = 23
8 Partially correct 41 ms 2476 KB Output is partially correct - L* = 21
9 Partially correct 43 ms 2520 KB Output is partially correct - L* = 20
10 Partially correct 45 ms 2516 KB Output is partially correct - L* = 25
11 Partially correct 44 ms 2516 KB Output is partially correct - L* = 22
12 Partially correct 41 ms 2524 KB Output is partially correct - L* = 24
13 Partially correct 55 ms 2420 KB Output is partially correct - L* = 21
14 Partially correct 41 ms 2544 KB Output is partially correct - L* = 23
15 Partially correct 41 ms 2488 KB Output is partially correct - L* = 21
16 Partially correct 44 ms 2460 KB Output is partially correct - L* = 23
17 Partially correct 44 ms 2368 KB Output is partially correct - L* = 21
18 Partially correct 41 ms 2488 KB Output is partially correct - L* = 20
19 Partially correct 50 ms 2524 KB Output is partially correct - L* = 24
20 Partially correct 41 ms 2468 KB Output is partially correct - L* = 21
21 Partially correct 49 ms 2396 KB Output is partially correct - L* = 20
22 Partially correct 44 ms 2476 KB Output is partially correct - L* = 23
23 Partially correct 43 ms 2448 KB Output is partially correct - L* = 20
24 Partially correct 43 ms 2508 KB Output is partially correct - L* = 23
25 Partially correct 46 ms 2528 KB Output is partially correct - L* = 24
26 Partially correct 46 ms 2492 KB Output is partially correct - L* = 26
27 Partially correct 43 ms 2512 KB Output is partially correct - L* = 22
28 Partially correct 41 ms 2444 KB Output is partially correct - L* = 21
29 Partially correct 44 ms 2516 KB Output is partially correct - L* = 20
30 Partially correct 43 ms 2520 KB Output is partially correct - L* = 20
31 Partially correct 46 ms 2576 KB Output is partially correct - L* = 24
32 Partially correct 46 ms 2488 KB Output is partially correct - L* = 20
33 Partially correct 43 ms 2368 KB Output is partially correct - L* = 20
34 Partially correct 41 ms 2584 KB Output is partially correct - L* = 28
35 Partially correct 41 ms 2528 KB Output is partially correct - L* = 21
36 Partially correct 41 ms 2452 KB Output is partially correct - L* = 21
37 Partially correct 44 ms 2424 KB Output is partially correct - L* = 21
38 Partially correct 41 ms 2436 KB Output is partially correct - L* = 22
39 Partially correct 48 ms 2612 KB Output is partially correct - L* = 21
40 Partially correct 43 ms 2500 KB Output is partially correct - L* = 21