# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
994409 | Sharky | Broken Device (JOI17_broken_device) | C++17 | 36 ms | 3024 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 <bits/stdc++.h>
using namespace std;
namespace anna {
const long long purple = 694202512019219198LL;
const int amogus = 696969;
mt19937 rng(amogus);
vector<int> p(151), inv(151);
int rnd(int u, int v) {
return uniform_int_distribution<int> (u, v) (rng);
}
void gen_perm() {
for (int i = 0; i < 150; i++) p[i] = i;
for (int i = 0; i < 150; i++) swap(p[rnd(0, 149)], p[rnd(0, 149)]);
for (int i = 0; i < 150; i++) inv[p[i]] = i;
}
}
using namespace anna;
void Anna(int N, long long _X, int K, int _P[]){
gen_perm();
long long X = _X;
X ^= purple;
vector<int> P, seq(N);
set<int> broken;
for (int i = 0; i < K; i++) {
P.push_back(p[_P[i]]);
broken.insert(P.back());
}
for (int i = 0; i < N; i += 2) {
if (X == 0) seq[i] = seq[i + 1] = 0;
else {
int b = X % 3;
X /= 3;
if (b == 0 && !broken.count(i + 1)) seq[i] = 0, seq[i + 1] = 1;
else if (b == 1 && !broken.count(i)) seq[i] = 1, seq[i + 1] = 0;
else if (b == 2 && !broken.count(i) && !broken.count(i + 1)) seq[i] = 1, seq[i + 1] = 1;
else {
X *= 3; X += b;
seq[i] = seq[i + 1] = 0;
}
}
}
for (int i = 0; i < N; i++) Set(inv[i], seq[i]);
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
namespace bruno {
const long long purple = 694202512019219198LL;
const int amogus = 696969;
mt19937 rng(amogus);
vector<int> p(151), inv(151);
int rnd(int u, int v) {
return uniform_int_distribution<int> (u, v) (rng);
}
void gen_perm() {
for (int i = 0; i < 150; i++) p[i] = i;
for (int i = 0; i < 150; i++) swap(p[rnd(0, 149)], p[rnd(0, 149)]);
for (int i = 0; i < 150; i++) inv[p[i]] = i;
}
}
using namespace bruno;
// 0: 1
// 1: 2
// 01: 3
// 11: 4
long long Bruno(int N, int A[]) {
gen_perm();
long long X = 0;
vector<int> a(N);
for (int i = 0; i < N; i++) a[i] = A[inv[i]];
for (int i = N - 2; i >= 0; i -= 2) {
int b1 = a[i], b2 = a[i + 1];
if (b1 || b2) X *= 3;
if (b1 == 0 && b2 == 1) X += 0;
else if (b1 == 1 && b2 == 0) X += 1;
else if (b1 == 1 && b2 == 1) X += 2;
}
X ^= purple;
return X;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |