Submission #69080

# Submission time Handle Problem Language Result Execution time Memory
69080 2018-08-19T22:32:36 Z IvanC Broken Device (JOI17_broken_device) C++17
8 / 100
80 ms 3968 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 150;

static int possivel[MAXN],resposta[MAXN];

void Anna( int N, long long X, int K, int P[] ){

	memset(possivel,1,sizeof(possivel));
	memset(resposta,0,sizeof(resposta));
	possivel[N] = 0;

	for(int i = 0;i<K;i++) possivel[P[i]] = 0;

	deque<int> digitos;
	while(X != 0){
		digitos.push_back(X % 2);
		X /= 2;
	}
	for(int i = 0;i<100;i++) digitos.push_back(0);

	for(int i = 0;i+2<N;i+=3){
		int nao_pode = (possivel[i] + 2*possivel[i+1] + 4*possivel[i+2]) ^ 7;
		int best_qtd = 0,mascara = 0;
		if(digitos.front() == 0){
			if(!(nao_pode & 4) && digitos[1] == 1){
				best_qtd = 2;
				mascara = 4;
			}
			else if(!(nao_pode & 1) && digitos[1] == 0){
				best_qtd = 2;
				mascara = 1;
			}
		}
		else{
			if(!(nao_pode & 3)){
				best_qtd = 1;
				mascara = 3;
			}
			else if(!(nao_pode & 5)){
				best_qtd = 1;
				mascara = 5;
			}
			if(!(nao_pode & 6) && digitos[1] == 1){
				best_qtd = 2;
				mascara = 6;
			}
			else if(!(nao_pode & 7) && digitos[1] == 1){
				best_qtd = 2;
				mascara = 7;
			}
		}
		for(int j = 0;j<best_qtd;j++) digitos.pop_front();
		resposta[i] = (mascara & 1) != 0;
		resposta[i+1] = (mascara & 2) != 0;
		resposta[i+2] = (mascara & 4) != 0;
	}

	for(int i = 0;i<N;i++){
		Set( i, resposta[i] );
	}

}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;

long long Bruno( int N, int A[] ){

	vector<int> digitos;
	long long ans = 0;

	for(int i = 0;i+2<N;i+=3){
		int numero = A[i] + 2*A[i+1] + 4*A[i+2];
		if(numero == 0) continue;
		if(numero == 4){
			digitos.push_back(0);
			digitos.push_back(1);
		}
		else if(numero == 1){
			digitos.push_back(0);
			digitos.push_back(0);
		}
		else if(numero == 2){
			digitos.push_back(1);
			digitos.push_back(0);
		}
		else if(numero == 7){
			digitos.push_back(1);
			digitos.push_back(1);
		}
		else if(numero != 0){
			digitos.push_back(1);
			if(numero == 6){
				digitos.push_back(1);
			}
		}
	}

	while(!digitos.empty() && digitos.back() == 0){
		digitos.pop_back();
	}
	for(int i = 0;i<digitos.size();i++){
		if(digitos[i]) ans += (1LL << i);
	}

	return ans;

}

Compilation message

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:40:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0;i<digitos.size();i++){
                ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 57 ms 2808 KB Output is partially correct - L* = 16
2 Partially correct 46 ms 3224 KB Output is partially correct - L* = 14
3 Partially correct 49 ms 3528 KB Output is partially correct - L* = 14
4 Partially correct 53 ms 3584 KB Output is partially correct - L* = 18
5 Partially correct 62 ms 3712 KB Output is partially correct - L* = 15
6 Partially correct 55 ms 3712 KB Output is partially correct - L* = 14
7 Partially correct 65 ms 3928 KB Output is partially correct - L* = 15
8 Partially correct 46 ms 3928 KB Output is partially correct - L* = 17
9 Partially correct 48 ms 3928 KB Output is partially correct - L* = 16
10 Partially correct 62 ms 3960 KB Output is partially correct - L* = 16
11 Partially correct 70 ms 3960 KB Output is partially correct - L* = 18
12 Partially correct 48 ms 3960 KB Output is partially correct - L* = 16
13 Partially correct 80 ms 3960 KB Output is partially correct - L* = 14
14 Partially correct 61 ms 3960 KB Output is partially correct - L* = 17
15 Partially correct 62 ms 3960 KB Output is partially correct - L* = 15
16 Partially correct 60 ms 3960 KB Output is partially correct - L* = 17
17 Partially correct 52 ms 3960 KB Output is partially correct - L* = 17
18 Partially correct 55 ms 3960 KB Output is partially correct - L* = 18
19 Partially correct 69 ms 3960 KB Output is partially correct - L* = 16
20 Partially correct 47 ms 3960 KB Output is partially correct - L* = 14
21 Partially correct 48 ms 3960 KB Output is partially correct - L* = 15
22 Partially correct 47 ms 3960 KB Output is partially correct - L* = 16
23 Partially correct 47 ms 3960 KB Output is partially correct - L* = 17
24 Partially correct 54 ms 3960 KB Output is partially correct - L* = 19
25 Partially correct 51 ms 3960 KB Output is partially correct - L* = 17
26 Partially correct 73 ms 3960 KB Output is partially correct - L* = 15
27 Partially correct 50 ms 3960 KB Output is partially correct - L* = 19
28 Partially correct 61 ms 3960 KB Output is partially correct - L* = 14
29 Partially correct 50 ms 3960 KB Output is partially correct - L* = 18
30 Partially correct 54 ms 3960 KB Output is partially correct - L* = 17
31 Partially correct 47 ms 3960 KB Output is partially correct - L* = 20
32 Partially correct 50 ms 3960 KB Output is partially correct - L* = 22
33 Partially correct 55 ms 3960 KB Output is partially correct - L* = 14
34 Partially correct 52 ms 3960 KB Output is partially correct - L* = 15
35 Partially correct 50 ms 3960 KB Output is partially correct - L* = 14
36 Partially correct 55 ms 3968 KB Output is partially correct - L* = 19
37 Partially correct 63 ms 3968 KB Output is partially correct - L* = 16
38 Partially correct 57 ms 3968 KB Output is partially correct - L* = 17
39 Partially correct 50 ms 3968 KB Output is partially correct - L* = 15
40 Partially correct 47 ms 3968 KB Output is partially correct - L* = 21