Submission #470315

# Submission time Handle Problem Language Result Execution time Memory
470315 2021-09-03T13:16:17 Z Omegaman Broken Device (JOI17_broken_device) C++14
Compilation error
0 ms 0 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;
	}
  

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:37:8: warning: unused variable 'bp' [-Wunused-variable]
   37 |    int bp = f1*4+f2*2+f3*1;
      |        ^~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:48:2: error: expected '}' at end of input
   48 |  }
      |  ^
Bruno.cpp:3:35: note: to match this '{'
    3 | long long Bruno( int N, int A[] ) {
      |                                   ^
Bruno.cpp:48:2: warning: no return statement in function returning non-void [-Wreturn-type]
   48 |  }
      |  ^