# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1164614 | Thanhs | Broken Device (JOI17_broken_device) | C++20 | 0 ms | 320 KiB |
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
#define name "TENBAI"
#define fi first
#define se second
#define setmin(x, y) x = min((x), (y))
#define setmax(x, y) x = max((x), (y))
#define sqr(x) ((x) * (x))
int v[] = {1, 2, 3};
vector<int> P(150);
bool bl[150];
void Anna(int n, long long x, int k, int p[])
{
if (n == 3)
{
if (x == 14)
Set(0, 0), Set(1, 1), Set(2, 0);
else
Set(0, 0), Set(1, 0), Set(2, 0);
return;
}
iota(P.begin(), P.end(), 0);
shuffle(P.begin(), P.end(), mt19937(69420));
for (int i = 0; i < k; i++)
bl[p[i]] = 1;
int cr = 0;
while (x)
{
while (1)
{
int t = bl[P[cr]] + bl[P[cr + 1]] * 2;
if (t & v[x % 3])
{
Set(P[cr], 0);
Set(P[cr + 1], 0);
cr += 2;
continue;
}
Set(P[cr], v[x % 3] & 1);
Set(P[cr + 1], v[x % 3] >> 1 & 1);
cr += 2;
break;
}
x /= 3;
}
while (cr < 150)
Set(P[cr], 0), cr++;
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
#define name "TENBAI"
#define fi first
#define se second
#define setmin(x, y) x = min((x), (y))
#define setmax(x, y) x = max((x), (y))
#define sqr(x) ((x) * (x))
namespace B
{
vector<int> P(150);
bool bl[150];
int v[] = {0, 0, 1, 2};
long long solve(int n, int a[])
{
if (n == 3)
return a[1] ? 14 : 9;
iota(P.begin(), P.end(), 0);
shuffle(P.begin(), P.end(), mt19937(69420));
long long res = 0, cr = 1;
for (int i = 0; i < 150; i += 2)
{
if (!a[P[i]] && !a[P[i + 1]])
continue;
res = res + v[a[P[i]] + a[P[i + 1]] * 2] * cr;
cr *= 3;
}
return res;
}
}
long long Bruno(int n, int a[])
{
return B::solve(n, a);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |