# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1149160 | duckindog | Broken Device (JOI17_broken_device) | C++20 | 0 ms | 320 KiB |
#include <bits/stdc++.h>
using namespace std;
#include "Annalib.h"
void Anna( int N, long long X, int K, int P[] ){
vector<int> per(N); iota(per.begin(), per.end(), 0);
shuffle(per.begin(), per.end(), mt19937_64(149973));
vector<bool> work(N, true);
for (int i = 0; i < K; ++i)
work[P[i]] = false;
vector<int> num;
{ // decompose x into base 3
while (X) {
num.push_back(X % 3);
X /= 3;
}
while (num.size() < 38) num.push_back(0);
}
auto chk = [&](int pos0, int pos1, int value) {
int statePos = (pos0 << 1) | (pos1 << 0);
int stateVal = value + 1;
return statePos & stateVal == statePos;
};
for (int i = 0; i < N; i += 2) {
int pos0 = per[i], pos1 = per[i + 1];
if (!chk(pos0, pos1, num.back())) continue;
Set(pos0, (num.back() + 1) >> 1 & 1);
Set(pos1, (num.back() + 1) & 1);
num.pop_back();
}
}
#include <bits/stdc++.h>
using namespace std;
#include "Brunolib.h"
long long Bruno( int N, int A[] ){
vector<int> per(N); iota(per.begin(), per.end(), 0);
shuffle(per.begin(), per.end(), mt19937_64(149973));
long long X = 0;
for (int i = 0; i < N; i += 2) {
int pos0 = per[i], pos1 = per[i + 1];
if (!pos0 && !pos1) continue;
int value = ((pos0 << 1) | (pos1 << 0)) - 1;
X = X * 3 + value;
}
return X;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |