# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63298 | Arturgo | Broken Device (JOI17_broken_device) | C++14 | 81 ms | 12136 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 <iostream>
#include <vector>
#include "Annalib.h"
using namespace std;
vector<vector<int>> motifs = {
{1, 1, 1},
{1, 1, 0},
{0, 1, 1},
{0, 0, 1},
{1, 0, 1},
{0, 1, 0},
{1, 0, 0},
{0, 0, 0}
};
vector<vector<int>> reponses = {
{1, 1},
{1, 0},
{0, 1},
{0, 0},
{1},
{1},
{0},
{}
};
void Anna(int N, long long X, int K, int P[]) {
vector<int> broken(N, 0);
for(int iBroken = 0;iBroken < K;iBroken++) {
broken[P[iBroken]] = 1;
}
vector<bool> number(1000, 0);
for(int iBit = 0;iBit < 60;iBit++) {
number[iBit] = X % 2;
X /= 2;
}
int it = 0;
for(int pos = 0;pos < N/3;pos++) {
for(int iMotif = 0;iMotif < 8;iMotif++) {
bool estValide = true;
for(int iBit = 0;iBit < 3;iBit++)
if(broken[3 * pos + iBit] == 1 && motifs[iMotif][iBit] == 1)
estValide = false;
for(int iBit = 0;iBit < reponses[iMotif].size();iBit++)
if(reponses[iMotif][iBit] != number[it + iBit])
estValide = false;
if(estValide) {
for(int iBit = 0;iBit < 3;iBit++) {
Set(3 * pos + iBit, motifs[iMotif][iBit]);
}
it += reponses[iMotif].size();
break;
}
}
}
for(int iBit = 3 * (N / 3);iBit < N;iBit++) {
Set(iBit, 0);
}
}
#include <iostream>
#include <vector>
#include "Brunolib.h"
using namespace std;
vector<vector<int>> motifs = {
{1, 1, 1},
{1, 1, 0},
{0, 1, 1},
{0, 0, 1},
{1, 0, 1},
{0, 1, 0},
{1, 0, 0},
{0, 0, 0}
};
vector<vector<int>> reponses = {
{1, 1},
{1, 0},
{0, 1},
{0, 0},
{1},
{1},
{0},
{}
};
long long Bruno(int N, int A[]) {
long long X = 0, exp = 1;
for(int pos = 0;pos < N / 3;pos++) {
for(int iMotif = 0;iMotif < 8;iMotif++) {
bool estValide = true;
for(int iBit = 0;iBit < 3;iBit++)
if(A[3 * pos + iBit] != motifs[iMotif][iBit])
estValide = false;
if(estValide) {
for(int bit : reponses[iMotif]) {
X += bit * exp;
exp *= 2;
}
}
}
}
return X;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |