# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
535494 | flappybird | Broken Device (JOI17_broken_device) | C++17 | 46 ms | 2728 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 pair<int, int> pi;
typedef long long ll;
#define MAX 153
int res[MAX];
bool chkb[MAX];
int arr[MAX];
int ptr;
void print(int i) {
int a, b, c;
a = 3 * i;
b = a + 1;
c = a + 2;
int rs = chkb[a] + chkb[b] + chkb[c];
if (rs >= 2) return;
vector<int> tx;
if (rs == 0) {
int x = arr[ptr] * 2 + arr[ptr + 1];
ptr += 2;
if (x == 0) tx = { 0, 1, 1 };
if (x == 1) tx = { 0, 0, 1 };
if (x == 2) tx = { 1, 1, 0 };
if (x == 3) tx = { 1, 1, 1 };
}
else {
if (chkb[a]) {
if (arr[ptr]) tx = { 0, 1, 0 }, ptr++;
else {
if (arr[ptr + 1]) tx = { 0, 0, 1 };
else tx = { 0, 1, 1 };
ptr += 2;
}
}
else {
if (arr[ptr]) tx = chkb[b] ? (vector<int>{ 1, 0, 1 }) : vector<int>{ 0, 1, 0 };
else tx = { 1, 0, 0 };
ptr += 1;
}
}
tie(res[a], res[b], res[c]) = tie(tx[0], tx[1], tx[2]);
}
void Anna(int N, long long X, int K, int P[]) {
memset(res, 0, sizeof(res));
memset(arr, 0, sizeof(arr));
memset(chkb, 0, sizeof(chkb));
ptr = 0;
int i;
for (i = 0; i < 60; i++) if (X & (1LL << (ll)(59 - i))) arr[i] = 1;
for (i = 0; i < K; i++) chkb[P[i]] = true;
for (i = 0; i < 50; i++) print(i);
for (i = 0; i < 150; i++) Set(i, res[i]);
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<vector<int>> vv = { {}, {0, 1}, {1}, {0, 0}, {0}, {1}, {1, 0}, {1, 1} };
int get(int a, int b, int c) {
return a * 4 + b * 2 + c;
}
long long Bruno( int N, int A[] ){
ll res = 0;
int i;
int a, b, c;
a = 0;
b = 1;
c = 2;
vector<int> bits;
for (i = 0; i < 50; i++) {
int x = get(A[a], A[b], A[c]);
bits.insert(bits.end(), vv[x].begin(), vv[x].end());
a += 3;
b += 3;
c += 3;
}
for (i = 0; i < 60; i++) if (bits[i]) res += 1LL << (ll)(59 - i);
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |