# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
470680 | jjang36524 | Broken Device (JOI17_broken_device) | C++14 | 41 ms | 2628 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 "Brunolib.h"
int arr[200];
void Anna( int N, long long X, int K, int P[] )
{
int i;
for (i = 0; i < N; i++)
{
arr[i] = 0;
}
for (i = 0; i < K; i++)
{
arr[P[i]] = 1;
}
for(i = 0; i < N;)
{
int c = 0;
int j;
for (j = 0; j < 3; j++)
{
if (arr[i + j])
{
c += 1 << j;
}
}
if (c == 0)
{
if (X % 4 == 0)
{
Set(i, 1);
Set(i + 1, 0);
Set(i + 2, 0);
}
else if (X % 4 == 1)
{
Set(i, 1);
Set(i + 1, 0);
Set(i + 2, 1);
}
else if (X % 4 == 2)
{
Set(i, 1);
Set(i + 1, 1);
Set(i + 2, 1);
}
else if (X % 4 == 3)
{
Set(i, 0);
Set(i + 1, 1);
Set(i + 2, 1);
}
X /= 4;
}
else if (c == 1)
{
if (X % 2)
{
Set(i, 0);
Set(i + 1, 0);
Set(i + 2, 1);
}
else
{
Set(i, 0);
Set(i + 1, 1);
Set(i + 2, 0);
}
X /= 2;
}
else if (c == 2)
{
if (X % 2)
{
Set(i, 0);
Set(i + 1, 0);
Set(i + 2, 1);
X /= 2;
}
else
{
if (X % 4)
{
Set(i, 1);
Set(i + 1, 0);
Set(i + 2, 1);
}
else
{
Set(i, 1);
Set(i + 1, 0);
Set(i + 2, 0);
}
X /= 4;
}
}
else if (c == 4)
{
if (X % 2)
{
Set(i, 1);
Set(i + 1, 1);
Set(i + 2, 0);
}
else
{
Set(i, 0);
Set(i + 1, 1);
Set(i + 2, 0);
}
X /= 2;
}
else
{
Set(i, 0);
Set(i + 1, 0);
Set(i + 2, 0);
}
i += 3;
}
}
#include "Annalib.h"
#include "Brunolib.h"
long long Bruno(int N, int A[])
{
long long ans = 0;
int i;
int t = 0;
for (i = 0; i < N;i+=3)
{
if (t > 60)
break;
int x = 0;
int j;
for (j = 0; j < 3; j++)
{
if (A[i + j])
{
x += (1 << j);
}
}
if (x == 1)
{
t += 2;
}
else if (x == 2)
{
t++;
}
else if (x == 3)
{
ans += 1LL << t;
t++;
}
else if (x == 4)
{
ans += 1LL << t;
t++;
}
else if (x == 5)
{
ans += 1LL << t;
t += 2;
}
else if (x == 6)
{
ans += 3LL << t;
t += 2;
}
else if (x == 7)
{
ans += 2LL << t;
t += 2;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |