# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1219681 | The_Samurai | Broken Device (JOI17_broken_device) | C++20 | 0 ms | 320 KiB |
#include "Annalib.h"
#include "bits/stdc++.h"
using namespace std;
void Anna(int n, long long x, int k, int P[] ){
mt19937 rng(12142532);
auto rand = [&](int l, int r) -> int {
int x = rng();
return abs(x) % (r - l + 1) + l;
};
assert(k <= 14);
assert(n == 150);
vector<int> ord(n), val(n, 1);
for (int i = 0; i < n; i++) ord[i] = i;
for (int i = 0; i < n; i++) swap(ord[i], ord[rand(0, i)]);
for (int i = 0; i < k; i++) val[P[i]] = 0;
auto check = [&](long long x) -> bool {
vector<int> vec(62);
for (int i = 0; i <= 60; i++) vec[i] = x >> i & 1ll;
int i = 0, j = 0;
for (; i < n and j < 62; ) {
if (!val[i]) {
i++;
continue;
}
if (i + 2 >= n) break;
if (!val[i + 1] and vec[j]) {
i++;
continue;
}
if (!val[i + 2] and vec[j + 1]) {
i++;
continue;
}
i += 3;
j += 2;
}
if (j < 62) return false;
i = 0, j = 0;
for (; i < n and j < 62; ) {
if (!val[i]) {
Set(ord[i], 0);
i++;
continue;
}
if (i + 2 >= n) break;
if (!val[i + 1] and vec[j]) {
Set(ord[i], 0);
i++;
continue;
}
if (!val[i + 2] and vec[j + 1]) {
Set(ord[i], 0);
i++;
continue;
}
Set(ord[i], 1);
Set(ord[i + 1], vec[j]);
Set(ord[i + 2], vec[j + 1]);
i += 3;
j += 2;
}
for (; i < n; i++) Set(ord[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);
// assert(false);
}
#include "Brunolib.h"
#include "bits/stdc++.h"
using namespace std;
long long Bruno( int n, int a[] ){
mt19937 rng(12142532);
auto rand = [&](int l, int r) -> int {
int x = rng();
return abs(x) % (r - l + 1) + l;
};
vector<int> ord(n);
for (int i = 0; i < n; i++) ord[i] = i;
for (int i = 0; i < n; i++) swap(ord[i], ord[rand(0, i)]);
long long ans = 0;
int i = 0;
for (int j = 0; j < n; ) {
if (!a[ord[j]]) {
j++;
continue;
}
ans += (1ll << i) * a[ord[j + 1]];
ans += (1ll << (i + 1)) * a[ord[j + 2]];
i += 2;
j += 3;
}
// const long long N = (1ll << 61) - 1;
// if (ans >> 60 & 1) ans ^= N;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |