# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
21590 | Ushio | Broken Device (JOI17_broken_device) | C++14 | 52 ms | 4636 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 <algorithm>
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
void Anna(int N, long long X, int K, int P[] ){
vector<int> bits(N);
for (int i = 0; i < N; ++i) {
bits[i] = i >= 60 ? 0: ((X & (1LL << i)) != 0);
}
vector<int> bad(N, 0);
for (int i = 0; i < K; ++i) {
bad[P[i]] = 1;
}
int pos = 0;
for (int i = 0; i < N; i += 3) {
int cnt = bad[i] + bad[i + 1] + bad[i + 2];
if (cnt == 0) {
if (bits[pos] == 0 && bits[pos + 1] == 0) {
Set(i , 1);
Set(i + 1, 0);
Set(i + 2, 0);
} else if (bits[pos] == 0 && bits[pos + 1] == 1) {
Set(i , 1);
Set(i + 1, 0);
Set(i + 2, 1);
} else if (bits[pos + 1] == 0) {
Set(i , 0);
Set(i + 1, 1);
Set(i + 2, 1);
} else {
Set(i , 1);
Set(i + 1, 1);
Set(i + 2, 1);
}
pos += 2;
} else if (cnt == 1) {
if (bits[pos] == 0) {
if (!bad[i + 1]) {
Set(i , 0);
Set(i + 1, 1);
Set(i + 2, 0);
pos += 1;
} else if (bits[pos + 1] == 0) {
Set(i , 1);
Set(i + 1, 0);
Set(i + 2, 0);
pos += 2;
} else {
Set(i , 1);
Set(i + 1, 0);
Set(i + 2, 1);
pos += 2;
}
} else if (bad[i + 2]) {
Set(i , 1);
Set(i + 1, 1);
Set(i + 2, 0);
pos += 1;
} else {
Set(i , 0);
Set(i + 1, 0);
Set(i + 2, 1);
pos += 1;
}
} else {
Set(i, 0);
Set(i + 1, 0);
Set(i + 2, 0);
}
}
}
#include "Brunolib.h"
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
const int64_t value[] = {0, 1, 0, 1, 0, 2, 1, 3};
const int add[] = {0, 1, 1, 2, 2, 2, 1, 2};
long long Bruno( int N, int A[] ){
vector<int> bits(N, 0);
int64_t ans = 0;
int shift = 0;
for (int i = 0; i < N; i += 3) {
int v = 4 * A[i] + 2 * A[i + 1] + A[i + 2];
ans |= value[v] << shift;
shift += add[v];
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |