Submission #469074

# Submission time Handle Problem Language Result Execution time Memory
469074 2021-08-30T15:45:45 Z Omegaman Broken Device (JOI17_broken_device) C++14
0 / 100
42 ms 2876 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 true;
	return false;
}

void Anna(int N, long long X, int K, int P[]){
	const int xl = int(log2(X) + 0.5);

	bool d[N];
	long long x = X;
	for( int i = 0; i < N; i++ ){
		d[i] = x % 2;
		x /= 2;
	}

	bool F[N];

	for ( int i = 0; i < N; i++ ) {
		F[i] = !isInArr(K, P, i);
	}
	
	bool M[N];

	int dh = 0;
	int sc = 0;
	for( int i = 0; i < N; i++) {
		if (d[dh]) {
			if (F[i]) {
				M[i] = 1;
				dh++;
			} else {
				M[i + 0] = 0;
				M[i + 1] = 0;
				i++;
				sc++;
			}
		} else {
			if (sc < 40) {
				if (F[i + 1]) {
					M[i + 0] = 0;
					M[i + 1] = 1;
					dh++;
				} else {
					M[i + 0] = 0;
					M[i + 1] = 0;
					sc++;
				}
				i++;
			} else {
				M[i] = 0;
				dh++;
			}
		}
	}

	for ( int i = 0; i < N; i++ ) {
		Set(i, (int)M[i]);
	}
}
#include "Brunolib.h"

long long Bruno( int N, int A[] ) {
	long long X = 0;
	long long inc = 1;

	int len = (N < 60 ? N : 60);

	bool d[len];
	for( int i = 0; i < len; i++)
		d[i] = 0;

	int dh = 0;
	int sc = 0;
	for( int i = 0; i < N; i++) {
		if(A[i]) {
			d[dh] = 1;
			dh++;
		} else {
			if (sc < 40) {
				if (A[i + 1]) {
					d[dh] = 0;
					dh++;
				} else {
					sc++;
				}
				i++;
			} else {
				d[dh] = 0;
				dh++;
			}
		}
	}

	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:12:12: warning: unused variable 'xl' [-Wunused-variable]
   12 |  const int xl = int(log2(X) + 0.5);
      |            ^~
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 2524 KB Execution killed with signal 6
2 Runtime error 32 ms 2508 KB Execution killed with signal 6
3 Runtime error 29 ms 2580 KB Execution killed with signal 6
4 Runtime error 27 ms 2612 KB Execution killed with signal 6
5 Runtime error 27 ms 2648 KB Execution killed with signal 6
6 Runtime error 29 ms 2564 KB Execution killed with signal 6
7 Runtime error 30 ms 2640 KB Execution killed with signal 6
8 Runtime error 36 ms 2584 KB Execution killed with signal 6
9 Runtime error 27 ms 2696 KB Execution killed with signal 6
10 Runtime error 27 ms 2844 KB Execution killed with signal 6
11 Runtime error 27 ms 2580 KB Execution killed with signal 6
12 Runtime error 27 ms 2548 KB Execution killed with signal 6
13 Runtime error 27 ms 2636 KB Execution killed with signal 6
14 Runtime error 28 ms 2548 KB Execution killed with signal 6
15 Runtime error 39 ms 2608 KB Execution killed with signal 6
16 Runtime error 27 ms 2572 KB Execution killed with signal 6
17 Runtime error 28 ms 2556 KB Execution killed with signal 6
18 Runtime error 26 ms 2616 KB Execution killed with signal 6
19 Runtime error 30 ms 2596 KB Execution killed with signal 6
20 Runtime error 27 ms 2652 KB Execution killed with signal 6
21 Runtime error 27 ms 2576 KB Execution killed with signal 6
22 Runtime error 27 ms 2620 KB Execution killed with signal 6
23 Runtime error 42 ms 2596 KB Execution killed with signal 6
24 Runtime error 27 ms 2536 KB Execution killed with signal 6
25 Runtime error 31 ms 2576 KB Execution killed with signal 6
26 Runtime error 28 ms 2568 KB Execution killed with signal 6
27 Runtime error 27 ms 2572 KB Execution killed with signal 6
28 Runtime error 28 ms 2568 KB Execution killed with signal 6
29 Runtime error 27 ms 2652 KB Execution killed with signal 6
30 Runtime error 27 ms 2580 KB Execution killed with signal 6
31 Runtime error 27 ms 2632 KB Execution killed with signal 6
32 Runtime error 27 ms 2580 KB Execution killed with signal 6
33 Runtime error 29 ms 2548 KB Execution killed with signal 6
34 Runtime error 27 ms 2544 KB Execution killed with signal 6
35 Runtime error 27 ms 2572 KB Execution killed with signal 6
36 Runtime error 29 ms 2876 KB Execution killed with signal 6
37 Runtime error 27 ms 2596 KB Execution killed with signal 6
38 Runtime error 27 ms 2560 KB Execution killed with signal 6
39 Runtime error 27 ms 2620 KB Execution killed with signal 6
40 Runtime error 27 ms 2556 KB Execution killed with signal 6