# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83782 | nikolapesic2802 | Broken Device (JOI17_broken_device) | C++11 | 52 ms | 3312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |