Submission #83783

# Submission time Handle Problem Language Result Execution time Memory
83783 2018-11-10T14:20:29 Z nikolapesic2802 Broken Device (JOI17_broken_device) C++11
100 / 100
61 ms 3064 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(!(nao_pode & 4) && digitos[0] == 1){
			best_qtd = 1;
			mascara = 4;
		}
		if(!(nao_pode & 2) && digitos[0] == 0){
			best_qtd = 1;
			mascara = 2;
		}
		if(!(nao_pode & 3) && digitos[0] == 1){
			best_qtd = 1;
			mascara = 3;
		}
		if(!(nao_pode & 6) && digitos[0] == 1 && digitos[1] == 0){
			best_qtd = 2;
			mascara = 6;
		}
		if(!(nao_pode & 1) && digitos[0] == 0 && digitos[1] == 0){
			best_qtd = 2;
			mascara = 1;
		}
		if(!(nao_pode & 5) && digitos[0] == 0 && digitos[1] == 1){
			best_qtd = 2;
			mascara = 5;
		}
		if(!(nao_pode & 7) && digitos[0] == 1 && 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 || numero == 6 || numero == 3 || numero == 7){
			digitos.push_back(1);
			if(numero == 7) digitos.push_back(1);
			else if(numero == 6) digitos.push_back(0);
		}
		else{
			digitos.push_back(0);
			if(numero == 1) digitos.push_back(0);
			else if(numero == 5) 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:28: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 Correct 36 ms 3056 KB Output is correct - L* = 40
2 Correct 35 ms 3056 KB Output is correct - L* = 40
3 Correct 37 ms 3056 KB Output is correct - L* = 40
4 Correct 35 ms 3056 KB Output is correct - L* = 40
5 Correct 35 ms 3056 KB Output is correct - L* = 40
6 Correct 35 ms 3056 KB Output is correct - L* = 40
7 Correct 36 ms 3056 KB Output is correct - L* = 40
8 Correct 37 ms 3064 KB Output is correct - L* = 40
9 Correct 35 ms 3064 KB Output is correct - L* = 40
10 Correct 35 ms 3056 KB Output is correct - L* = 40
11 Correct 35 ms 3056 KB Output is correct - L* = 40
12 Correct 35 ms 3000 KB Output is correct - L* = 40
13 Correct 35 ms 3056 KB Output is correct - L* = 40
14 Correct 37 ms 3056 KB Output is correct - L* = 40
15 Correct 35 ms 3056 KB Output is correct - L* = 40
16 Correct 35 ms 3056 KB Output is correct - L* = 40
17 Correct 35 ms 3056 KB Output is correct - L* = 40
18 Correct 35 ms 3056 KB Output is correct - L* = 40
19 Correct 35 ms 3056 KB Output is correct - L* = 40
20 Correct 35 ms 3056 KB Output is correct - L* = 40
21 Correct 35 ms 3056 KB Output is correct - L* = 40
22 Correct 35 ms 3056 KB Output is correct - L* = 40
23 Correct 35 ms 3056 KB Output is correct - L* = 40
24 Correct 37 ms 3056 KB Output is correct - L* = 40
25 Correct 36 ms 3056 KB Output is correct - L* = 40
26 Correct 35 ms 3056 KB Output is correct - L* = 40
27 Correct 35 ms 3056 KB Output is correct - L* = 40
28 Correct 36 ms 3056 KB Output is correct - L* = 40
29 Correct 36 ms 3056 KB Output is correct - L* = 40
30 Correct 36 ms 3056 KB Output is correct - L* = 40
31 Correct 35 ms 3056 KB Output is correct - L* = 40
32 Correct 35 ms 3056 KB Output is correct - L* = 40
33 Correct 35 ms 3056 KB Output is correct - L* = 40
34 Correct 35 ms 3056 KB Output is correct - L* = 40
35 Correct 35 ms 3056 KB Output is correct - L* = 40
36 Correct 35 ms 3056 KB Output is correct - L* = 40
37 Correct 35 ms 3056 KB Output is correct - L* = 40
38 Correct 34 ms 3056 KB Output is correct - L* = 40
39 Correct 61 ms 3000 KB Output is correct - L* = 40
40 Correct 35 ms 3000 KB Output is correct - L* = 40