# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1147627 | andrei_iorgulescu | Broken Device (JOI17_broken_device) | C++20 | 32 ms | 1520 KiB |
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> perm = {9, 42, 17, 16, 121, 2, 80, 30, 104, 90, 61, 85, 130, 22, 106, 86, 88, 127, 105, 116, 136, 143, 146, 53, 84, 149, 120, 94, 119, 118, 4, 52, 56, 79, 89, 10, 25, 55, 18, 23, 115, 148, 135, 46, 128, 7, 26, 81, 69, 70, 129, 21, 29, 133, 95, 59, 101, 82, 102, 111, 35, 132, 77, 41, 140, 34, 109, 68, 51, 124, 27, 19, 67, 49, 24, 103, 1, 63, 114, 144, 12, 125, 5, 54, 73, 113, 141, 147, 145, 65, 39, 131, 3, 126, 92, 60, 72, 37, 93, 137, 96, 139, 78, 0, 11, 28, 76, 134, 36, 138, 14, 33, 44, 74, 122, 83, 31, 43, 112, 71, 20, 64, 98, 117, 100, 8, 40, 47, 97, 66, 91, 38, 142, 15, 62, 6, 57, 110, 99, 107, 13, 48, 123, 58, 32, 87, 50, 108, 75, 45};
//vector<int> perm = {0, 1, 2, 3, 4, 5};
vector<pair<int, int>> pairs;
void Anna(int N, ll X, int K, int P[])
{
pairs.clear();
for (int i = 0; i < N; i += 2)
pairs.push_back({perm[i], perm[i + 1]});
vector<bool> nope(N);
for (int i = 0; i < K; i++)
nope[P[i]] = true;
vector<ll> binX;
for (int i = 0; i < 38; i++)
{
binX.push_back(X % 3);
X /= 3;
}
int bt = 0;
for (auto it : pairs)
{
if (bt == 38)
{
Set(it.first, 0);
Set(it.second, 0);
}
else if (nope[it.first] or nope[it.second])
{
Set(it.first, 0);
Set(it.second, 0);
}
else
{
if (binX[bt] == 0)
{
Set(it.first, 0);
Set(it.second, 1);
}
else if (binX[bt] == 1)
{
Set(it.first, 1);
Set(it.second, 0);
}
else
{
Set(it.first, 1);
Set(it.second, 1);
}
bt++;
}
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> perm = {9, 42, 17, 16, 121, 2, 80, 30, 104, 90, 61, 85, 130, 22, 106, 86, 88, 127, 105, 116, 136, 143, 146, 53, 84, 149, 120, 94, 119, 118, 4, 52, 56, 79, 89, 10, 25, 55, 18, 23, 115, 148, 135, 46, 128, 7, 26, 81, 69, 70, 129, 21, 29, 133, 95, 59, 101, 82, 102, 111, 35, 132, 77, 41, 140, 34, 109, 68, 51, 124, 27, 19, 67, 49, 24, 103, 1, 63, 114, 144, 12, 125, 5, 54, 73, 113, 141, 147, 145, 65, 39, 131, 3, 126, 92, 60, 72, 37, 93, 137, 96, 139, 78, 0, 11, 28, 76, 134, 36, 138, 14, 33, 44, 74, 122, 83, 31, 43, 112, 71, 20, 64, 98, 117, 100, 8, 40, 47, 97, 66, 91, 38, 142, 15, 62, 6, 57, 110, 99, 107, 13, 48, 123, 58, 32, 87, 50, 108, 75, 45};
//vector<int> perm = {0, 1, 2, 3, 4, 5};
vector<pair<int, int>> pairs;
ll Bruno(int N, int A[])
{
pairs.clear();
for (int i = 0; i < N; i += 2)
pairs.push_back({perm[i], perm[i + 1]});
ll p3 = 1, x = 0;
for (auto it : pairs)
{
if (A[it.first] == 0 and A[it.second] == 0)
continue;
else if (A[it.first] == 1 and A[it.second] == 1)
x += 2ll * p3, p3 *= 3ll;
else if (A[it.first] == 1)
x += p3, p3 *= 3ll;
else
p3 *= 3ll;
}
return x;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |