# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123097 | tjd229 | Broken Device (JOI17_broken_device) | C++11 | 45 ms | 3064 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"
void Anna(int N, long long X, int K, int P[]) {
int mem[150];
int b[70] = { 0 };
for (int i = 0; i < N; ++i) mem[i] = 1;
for (int i = 0; i < K; ++i) mem[P[i]] = 0;
for (int i = 0; X; ++i,X>>=1)
b[i] = X & 1;
int pos = 0;
for (int i = 0; i < N; i += 3) {
int s = mem[i] + mem[i + 1] + mem[i + 2];
int mask = (mem[i] << 2) + mem[i + 1] + mem[i + 1] + mem[i + 2];
int w = 0;
if (pos >= 60) {
mem[i] = mem[i + 1] = mem[i + 2] = 0;
continue;
}
if (mask == 7 && b[pos] + b[pos + 1]==2) {
w = 7;
pos += 2;
}
else if ((mask & 2) == 2 && b[pos] + b[pos + 1] == 0) {
w = 2;
pos += 2;
}
else if ((mask & 5)==5 && b[pos]==1&& b[pos + 1] == 0) {
w = 5;
pos += 2;
}
else if ((mask & 3)==3 && b[pos] == 0 && b[pos + 1] == 1) {
w = 3;
pos += 2;
}
else if ((mask & 6)==6 && b[pos]) {
w = 6;
++pos;
}
else if ((mask & 1) &&b[pos]) {
w = 1;
++pos;
}
else if ((mask & 4) == 4 && b[pos] == 0 ) {
w = 4;
++pos;
}
mem[i] = (w & 4) >> 2;
mem[i + 1] = (w&2) >> 1;
mem[i + 2] = w & 1;
}
for (int i = 0; i < N; ++i) Set(i, mem[i]);
}
#include "Brunolib.h"
long long Bruno( int N, int A[] ){
long long X = 0;
int recon[70] = { 0 };
int pos = 0;
for (int i = 0; i < N; i += 3) {
int mask = (A[i] << 2) + A[i + 1] + A[i + 1] + A[i + 2];
if (mask == 1 || mask == 6) recon[pos++] = 1;
else if (mask == 2) pos += 2;
else if (mask == 3) recon[++pos] = 1, ++pos;
else if (mask == 4) ++pos;
else if (mask == 5) recon[pos++] = 1, ++pos;
else if (mask == 7)
recon[pos] = recon[pos + 1] = 1, pos += 2;
}
//printf("%d\n",pos);
pos = 60;
while (pos--) {
X <<= 1;
X += recon[pos];
}
return X;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |