#include "Annalib.h"
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
vector<int> ord = {138,6,105,87,111,3,123,63,141,36,66,54,30,45,129,147,27,84,135,24,12,21,57,126,102,9,75,144,99,117,96,18,132,69,42,114,0,93,108,120,60,72,90,33,48,81,39,78,51,15};
bool broken[150];
void Anna(int N, long long X, int K, int P[])
{
rep(i, 150) broken[i] = false;
rep(i, K) broken[P[i]] = true;
LL pw = 1;
while(pw + pw <= X) pw *= 3;
vector<int> bits;
while(X > 0) {
int cc = 0;
while(X >= pw) cc ++, X -= pw;
bits.push_back(cc);
pw /= 3;
}
while(pw > 0) {
bits.push_back(0);
pw /= 3;
}
reverse(bits.begin(), bits.end());
while(bits.back() == 0) bits.pop_back();
int ptr = 0;
for(int i : ord) {
int sum = 0;
if(!broken[i + 0]) sum ++;
if(!broken[i + 1]) sum ++;
if(!broken[i + 2]) sum ++;
if(ptr >= (int) bits.size() || sum == 0) {
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 0);
continue;
}
if(bits[ptr] == 0) {
if(!broken[i + 0]) {
Set(i + 0, 1);
Set(i + 1, 0);
Set(i + 2, 0);
ptr ++;
continue;
}
if(!broken[i + 1] && !broken[i + 2]) {
Set(i + 0, 0);
Set(i + 1, 1);
Set(i + 2, 1);
ptr ++;
continue;
}
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 0);
continue;
}
if(bits[ptr] == 1) {
if(!broken[i + 1]) {
Set(i + 0, 0);
Set(i + 1, 1);
Set(i + 2, 0);
ptr ++;
continue;
}
if(!broken[i + 0] && !broken[i + 2]) {
Set(i + 0, 1);
Set(i + 1, 0);
Set(i + 2, 1);
ptr ++;
continue;
}
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 0);
continue;
}
if(bits[ptr] == 2) {
if(!broken[i + 2]) {
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 1);
ptr ++;
continue;
}
if(!broken[i + 0] && !broken[i + 1]) {
Set(i + 0, 1);
Set(i + 1, 1);
Set(i + 2, 0);
ptr ++;
continue;
}
Set(i + 0, 0);
Set(i + 1, 0);
Set(i + 2, 0);
continue;
}
ptr ++;
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> ord = {138,6,105,87,111,3,123,63,141,36,66,54,30,45,129,147,27,84,135,24,12,21,57,126,102,9,75,144,99,117,96,18,132,69,42,114,0,93,108,120,60,72,90,33,48,81,39,78,51,15};
long long Bruno(int N, int A[])
{
long long X = 0, pw = 1;
for(int i : ord) {
int sum = A[i] + A[i + 1] + A[i + 2];
for(int j = 0; j < 3; j++) {
if(sum == 1 && A[i + j] == 1) {
X += pw * j;
pw *= 3;
}
if(sum == 2 && A[i + j] == 0) {
X += pw * j;
pw *= 3;
}
}
}
return X;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
28 ms |
2248 KB |
Output is partially correct - L* = 33 |
2 |
Partially correct |
34 ms |
2272 KB |
Output is partially correct - L* = 34 |
3 |
Partially correct |
28 ms |
2320 KB |
Output is partially correct - L* = 34 |
4 |
Partially correct |
31 ms |
2228 KB |
Output is partially correct - L* = 31 |
5 |
Partially correct |
30 ms |
2308 KB |
Output is partially correct - L* = 36 |
6 |
Partially correct |
33 ms |
2352 KB |
Output is partially correct - L* = 33 |
7 |
Partially correct |
30 ms |
2396 KB |
Output is partially correct - L* = 37 |
8 |
Partially correct |
27 ms |
2272 KB |
Output is partially correct - L* = 34 |
9 |
Partially correct |
28 ms |
2280 KB |
Output is partially correct - L* = 29 |
10 |
Partially correct |
34 ms |
2324 KB |
Output is partially correct - L* = 35 |
11 |
Partially correct |
30 ms |
2292 KB |
Output is partially correct - L* = 37 |
12 |
Partially correct |
32 ms |
2332 KB |
Output is partially correct - L* = 33 |
13 |
Partially correct |
28 ms |
2292 KB |
Output is partially correct - L* = 35 |
14 |
Partially correct |
31 ms |
2260 KB |
Output is partially correct - L* = 28 |
15 |
Partially correct |
34 ms |
2200 KB |
Output is partially correct - L* = 35 |
16 |
Partially correct |
30 ms |
2232 KB |
Output is partially correct - L* = 32 |
17 |
Partially correct |
30 ms |
2272 KB |
Output is partially correct - L* = 32 |
18 |
Partially correct |
28 ms |
2248 KB |
Output is partially correct - L* = 31 |
19 |
Partially correct |
28 ms |
2344 KB |
Output is partially correct - L* = 27 |
20 |
Partially correct |
28 ms |
2248 KB |
Output is partially correct - L* = 30 |
21 |
Partially correct |
28 ms |
2252 KB |
Output is partially correct - L* = 31 |
22 |
Partially correct |
31 ms |
2248 KB |
Output is partially correct - L* = 31 |
23 |
Partially correct |
28 ms |
2248 KB |
Output is partially correct - L* = 30 |
24 |
Partially correct |
30 ms |
2228 KB |
Output is partially correct - L* = 36 |
25 |
Partially correct |
28 ms |
2228 KB |
Output is partially correct - L* = 28 |
26 |
Partially correct |
28 ms |
2396 KB |
Output is partially correct - L* = 35 |
27 |
Partially correct |
30 ms |
2248 KB |
Output is partially correct - L* = 36 |
28 |
Partially correct |
30 ms |
2244 KB |
Output is partially correct - L* = 36 |
29 |
Partially correct |
28 ms |
2416 KB |
Output is partially correct - L* = 31 |
30 |
Partially correct |
30 ms |
2240 KB |
Output is partially correct - L* = 29 |
31 |
Partially correct |
28 ms |
2260 KB |
Output is partially correct - L* = 37 |
32 |
Partially correct |
28 ms |
2396 KB |
Output is partially correct - L* = 31 |
33 |
Partially correct |
28 ms |
2228 KB |
Output is partially correct - L* = 37 |
34 |
Partially correct |
28 ms |
2384 KB |
Output is partially correct - L* = 32 |
35 |
Partially correct |
30 ms |
2248 KB |
Output is partially correct - L* = 33 |
36 |
Partially correct |
39 ms |
2296 KB |
Output is partially correct - L* = 32 |
37 |
Partially correct |
30 ms |
2212 KB |
Output is partially correct - L* = 31 |
38 |
Partially correct |
34 ms |
2244 KB |
Output is partially correct - L* = 37 |
39 |
Partially correct |
30 ms |
2296 KB |
Output is partially correct - L* = 28 |
40 |
Partially correct |
28 ms |
2272 KB |
Output is partially correct - L* = 36 |