# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
923175 | gawr_gura | Broken Device (JOI17_broken_device) | C++17 | 31 ms | 3500 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 == 2) {
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 == 2) {
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 == 0) {
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;
vector<int64_t> a(N);
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... |