# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
55096 | ksun48 | Broken Device (JOI17_broken_device) | C++14 | 84 ms | 3984 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;
typedef long long LL;
void done(vector<LL> message, vector<LL> perm){
for(int i = 0; i < message.size(); i++){
Set(i, message[perm[i]]);
}
}
void Anna(int N, long long X, int K, int P[]){
// shared initialization
static mt19937_64 mt1(4848333);
static mt19937_64 mt2(43338);
static LL B = 60;
LL Y = mt1() & ((1LL << B) - 1);
vector<LL> perm(N);
for(int i = 0; i < N; i++){
perm[i] = i;
}
for(int i = N-1; i >= 0; i--){
int d = mt2() % (i+1);
if(d < 0){
d += (i+1);
}
swap(perm[i], perm[d]);
}
// shared initialization
X ^= Y;
vector<LL> message(N, 0);
// boilerplate
// ----------------------------------
vector<LL> bad(N, 0);
for(int i = 0; i < K; i++){
bad[perm[P[i]]] = 1;
}
vector<LL> usable;
for(int i = 0; i * 2 < N; i++){
if(!bad[2*i] && !bad[2*i+1]){
usable.push_back(i);
}
}
// 01 10 11
vector<LL> num;
for(int i = 0; i < 38; i++){
num.push_back(1 + (X % 3));
X /= 3;
}
reverse(num.begin(), num.end());
for(int j = 0; j < num.size() && j < usable.size(); j++){
int a = usable[j];
message[2*a] = num[j] / 2;
message[2*a+1] = num[j] % 2;
}
// ----------------------------------
done(message, perm);
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
using namespace std;
long long Bruno(int N, int A[]){
// shared initialization
static mt19937_64 mt1(4848333);
static mt19937_64 mt2(43338);
static LL B = 60;
LL Y = mt1() & ((1LL << B) - 1);
vector<LL> perm(N);
for(int i = 0; i < N; i++){
perm[i] = i;
}
for(int i = N-1; i >= 0; i--){
int d = mt2() % (i+1);
if(d < 0){
d += (i+1);
}
swap(perm[i], perm[d]);
}
// shared initialization
vector<LL> message(N);
for(int i = 0; i < N; i++){
message[perm[i]] = A[i];
}
vector<LL> info(60, 0);
// boilerplate
// ----------------------------------
LL X = 0;
for(int i = 0; i * 2 < N; i++){
if(message[2*i] == 0 && message[2*i+1] == 0) continue;
LL r = message[2*i] * 2 + message[2*i+1] - 1;
X = (X * 3 + r);
}
// ----------------------------------
return X ^ Y;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |