# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
923174 | gawr_gura | Broken Device (JOI17_broken_device) | C++17 | 28 ms | 2656 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 <bits/stdc++.h>
#include "Annalib.h"
using namespace std;
void Anna(int N, long long X, int K, int P[]) {
vector<int> a(N);
vector<int> wrong(N);
for (int i = 0; i < K; i++) wrong[P[i]] = 1;
for (int i = 0; i < N; i += 3) {
if (wrong[i] + wrong[i + 1] + wrong[i + 2] == 0) {
int z = X % 4;
X /= 4;
if (z == 0b10) {
a[i + 1] = a[i + 2] = 1;
} else {
a[i] = 1;
a[i + 2] = z & 1;
a[i + 1] = z / 2;
}
} else if (wrong[i] + wrong[i + 1] + wrong[i + 2] == 1) {
int z = X % 4;
if (wrong[i]) {
if (z == 0b10) {
a[i + 1] = a[i + 2] = 1;
X /= 4;
} else {
a[i + 1 + (z & 1)] = 1;
X /= 2;
}
} else if (wrong[i + 1]) {
if (z / 2 == 0) {
a[i] = 1;
a[i + 2] = z & 1;
X /= 4;
} else if (z & 1) {
a[i + 2] = 1;
X /= 2;
}
} else {
if (z == 0b00) {
a[i] = 1;
X /= 4;
} else {
a[i + 1] = 1;
a[i] = z & 1;
X /= 2;
}
}
}
}
for (int i = 0; i < N; i++) Set(i, a[i]);
}
#include <bits/stdc++.h>
#include "Brunolib.h"
using namespace std;
long long Bruno(int N, int A[]) {
int64_t X = 0;
for (int i = N - 3; i >= 0; i -= 3) {
if (A[i] + A[i + 1] + A[i + 2] == 0) continue;
if (A[i] == 1) {
if (A[i + 1] == 1 && A[i + 2] == 0) {
X = X * 2 + 1;
} else {
X = (X * 2 + A[i + 1]) * 2 + A[i + 2];
}
} else {
if (A[i + 1] + A[i + 2] == 1) {
X = X * 2 + A[i + 2];
} else {
X = (X * 2 + 1) * 2;
}
}
}
return X;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |