Submission #310965

# Submission time Handle Problem Language Result Execution time Memory
310965 2020-10-08T21:19:42 Z andremfq Broken Device (JOI17_broken_device) C++17
100 / 100
52 ms 3584 KB
// Ivan Carvalho
// Broken Device - JOI SC 2017
#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] );
	}
 
}
// Ivan Carvalho
// Broken Device - JOI SC 2017
#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:30:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for(int i = 0;i<digitos.size();i++){
      |                ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 48 ms 3312 KB Output is correct - L* = 40
2 Correct 48 ms 3584 KB Output is correct - L* = 40
3 Correct 48 ms 3312 KB Output is correct - L* = 40
4 Correct 50 ms 3568 KB Output is correct - L* = 40
5 Correct 49 ms 3328 KB Output is correct - L* = 40
6 Correct 49 ms 3328 KB Output is correct - L* = 40
7 Correct 48 ms 3328 KB Output is correct - L* = 40
8 Correct 50 ms 3568 KB Output is correct - L* = 40
9 Correct 48 ms 3312 KB Output is correct - L* = 40
10 Correct 48 ms 3584 KB Output is correct - L* = 40
11 Correct 50 ms 3312 KB Output is correct - L* = 40
12 Correct 49 ms 3312 KB Output is correct - L* = 40
13 Correct 49 ms 3312 KB Output is correct - L* = 40
14 Correct 48 ms 3312 KB Output is correct - L* = 40
15 Correct 48 ms 3328 KB Output is correct - L* = 40
16 Correct 49 ms 3312 KB Output is correct - L* = 40
17 Correct 50 ms 3312 KB Output is correct - L* = 40
18 Correct 49 ms 3328 KB Output is correct - L* = 40
19 Correct 50 ms 3312 KB Output is correct - L* = 40
20 Correct 50 ms 3328 KB Output is correct - L* = 40
21 Correct 48 ms 3312 KB Output is correct - L* = 40
22 Correct 52 ms 3312 KB Output is correct - L* = 40
23 Correct 48 ms 3312 KB Output is correct - L* = 40
24 Correct 50 ms 3328 KB Output is correct - L* = 40
25 Correct 49 ms 3328 KB Output is correct - L* = 40
26 Correct 49 ms 3328 KB Output is correct - L* = 40
27 Correct 52 ms 3312 KB Output is correct - L* = 40
28 Correct 49 ms 3312 KB Output is correct - L* = 40
29 Correct 49 ms 3312 KB Output is correct - L* = 40
30 Correct 48 ms 3328 KB Output is correct - L* = 40
31 Correct 50 ms 3328 KB Output is correct - L* = 40
32 Correct 48 ms 3312 KB Output is correct - L* = 40
33 Correct 49 ms 3312 KB Output is correct - L* = 40
34 Correct 48 ms 3328 KB Output is correct - L* = 40
35 Correct 48 ms 3312 KB Output is correct - L* = 40
36 Correct 50 ms 3312 KB Output is correct - L* = 40
37 Correct 51 ms 3312 KB Output is correct - L* = 40
38 Correct 49 ms 3312 KB Output is correct - L* = 40
39 Correct 50 ms 3328 KB Output is correct - L* = 40
40 Correct 50 ms 3584 KB Output is correct - L* = 40