# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1029906 | borisAngelov | Broken Device (JOI17_broken_device) | C++17 | 37 ms | 3020 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;
void Anna(int N, long long X, int K, int P[])
{
int n = N;
long long x = X;
int k = K;
bool isBlocked[n + 1] = {};
for (int i = 0; i < n; ++i)
{
isBlocked[i] = false;
}
for (int i = 0; i < k; ++i)
{
isBlocked[P[i]] = true;
}
for (int i = 0; i < n / 2; ++i)
{
int digit = x % 3;
int pos1 = 2 * i;
int pos2 = 2 * i + 1;
bool flag = false;
if (digit == 0 && isBlocked[pos1] == false)
{
Set(pos1, 1);
Set(pos2, 0);
flag = true;
}
if (digit == 1 && isBlocked[pos2] == false)
{
Set(pos1, 0);
Set(pos2, 1);
flag = true;
}
if (digit == 2 && isBlocked[pos1] == false && isBlocked[pos2] == false)
{
Set(pos1, 1);
Set(pos2, 1);
flag = true;
}
if (flag == false)
{
Set(pos1, 0);
Set(pos2, 0);
}
else
{
x /= 3;
}
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
long long Bruno(int N, int A[])
{
int n = N;
int a[n + 1] = {};
for (int i = 0; i < n; ++i)
{
a[i] = A[i];
}
long long ans = 0;
long long curr = 1;
for (int i = 0; i < n / 2; ++i)
{
int pos1 = 2 * i;
int pos2 = 2 * i + 1;
if (a[pos1] + a[pos2] == 0) continue;
if (a[pos1] == 0 && a[pos2] == 1)
{
ans += curr;
}
if (a[pos1] == 1 && a[pos2] == 1)
{
ans += 2 * curr;
}
curr *= 3;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |