# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1223657 | The_Samurai | Broken Device (JOI17_broken_device) | C++20 | 19 ms | 1344 KiB |
#include "Annalib.h"
#include "bits/stdc++.h"
using namespace std;
void Anna(int n, long long x, int k, int P[] ){
assert(n == 150);
vector<int> val(n, 1);
for (int i = 0; i < k; i++) val[P[i]] = 0;
auto check = [&](long long x) -> bool {
vector<int> vec(61);
for (int i = 0; i <= 60; i++) vec[i] = x >> i & 1ll;
int i, j;
for (i = 0, j = 0; i < 150 and j < 61; i += 2) {
if (val[i] + val[i + 1] == 0) continue;
if (val[i] == 0 and val[i + 1] == 1 and vec[j] == 0) continue;
if (val[i] == 1 and val[i + 1] == 0 and vec[j] == 1) continue;
j++;
}
if (j < 61) return false;
for (i = 0, j = 0; i < 150 and j < 61; i += 2) {
bool cont = val[i] + val[i + 1] == 0;
cont |= val[i] == 0 and val[i + 1] == 1 and vec[j] == 0;
cont |= val[i] == 1 and val[i + 1] == 0 and vec[j] == 1;
if (cont) {
Set(i, 0); Set(i + 1, 0);
continue;
}
Set(i, 1);
Set(i + 1, vec[j++]);
}
for (; i < 150; i++) Set(i, 0);
return true;
};
if (check(x)) return;
const long long N = ((1ll << 61) - 1);
if (check(x ^ N)) return;
for (int i = 0; i < n; i++) Set(i, 0);
}
#include "Brunolib.h"
#include "bits/stdc++.h"
using namespace std;
long long Bruno( int n, int a[] ){
long long ans = 0;
for (int i = 0, j = 0; i < 150 and j < 61; i += 2) {
if (a[i] + a[i + 1] == 0) continue;
if (a[i + 1]) ans |= 1ll << j;
}
const long long N = ((1ll << 61) - 1);
return min(ans, ans ^ N);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |