# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
991276 | abczz | Broken Device (JOI17_broken_device) | C++14 | 31 ms | 2944 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 <iostream>
#include <random>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
void Anna( int N, long long X, int K, int P[] ){
mt19937_64 mt(69);
ll perm[150];
for (int i=0; i<N; ++i) {
perm[i] = i;
}
shuffle(perm, perm+N, mt);
bool B[150], F[150];
for (int i=0; i<N; ++i) B[i] = F[i] = 0;
for (int i=0; i<K; ++i) B[P[i]] = 1;
for (int i=0; i<N; i+=2) {
ll cur = X % 3;
if (B[perm[i]] && B[perm[i+1]]) continue;
else if (B[perm[i]] && (cur == 1 || cur == 2)) continue;
else if (B[perm[i+1]] && (!cur || cur == 2)) continue;
X /= 3;
if (!cur) F[perm[i+1]] = 1;
else if (cur == 1) F[perm[i]] = 1;
else F[perm[i]] = F[perm[i+1]] = 1;
if (!X) break;
}
for (int i=0; i<N; ++i) {
Set(i, F[i]);
}
}
#include "Brunolib.h"
#include <iostream>
#include <vector>
#include <random>
#include <algorithm>
#define ll long long
using namespace std;
long long Bruno( int N, int A[] ){
mt19937_64 mt(69);
ll x = 0, s = 1;
ll perm[150];
for (int i=0; i<N; ++i) {
perm[i] = i;
}
shuffle(perm, perm+N, mt);
for (int i=0; i<N; i+=2) {
if (A[perm[i]] && A[perm[i+1]]) {
x += s * 2;
s *= 3;
}
else if (A[perm[i]]) {
x += s;
s *= 3;
}
else if (A[perm[i+1]]) {
s *= 3;
}
}
return x;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |