#include "Annalib.h"
#include<bits/stdc++.h>
using namespace std;
/*
001->0
010->00
100->1
011->1
110->10
111->11
101->01
*/
void add(int id, int v1, int v2, int v3) {
Set(id, v1); Set(id + 1, v2); Set(id + 2, v3);
}
void Anna( int n, long long x, int k, int p[] ){
vector<int> f(n);
for(int i = 0; i < k; i++) f[p[i]] = 1;
// 0111
for(int i = 0; i < n; i += 3) {
if(f[i] + f[i + 1] + f[i + 2] == 0) {
if(x % 4 == 0) add(i, 0, 1, 0);
if(x % 4 == 1) add(i, 1, 0, 1);
if(x % 4 == 2) add(i, 1, 1, 0);
if(x % 4 == 3) add(i, 1, 1, 1);
x /= 4;
continue;
}
if(f[i] + f[i + 1] + f[i + 2] == 1) {
if(x % 2 == 0) {
if(!f[i + 2]) add(i, 0, 0, 1), x /= 2;
else if(x % 4 == 0) add(i, 0, 1, 0), x /= 4;
else add(i, 1, 1, 0), x /= 4;
continue;
}
if(!f[i]) add(i, 1, 0, 0);
else add(i, 0, 1, 1);
x /= 2;
} else add(i, 0, 0, 0);
}
}
/*
2
150 9 2
0 1 */
#include "Brunolib.h"
/*
001->0
010->00
100->1
011->1
110->10
111->11
101->01
*/
long long Bruno( int n, int A[] ){
long long ans = 0, c = 0;
for(int i = 0; i < n; i += 3) {
int x = A[i] * 4 + A[i + 1] * 2 + A[i + 2];
if(!x) continue;
if(x == 1) ++c;
else if(x == 2) c += 2;
else if(x == 3 || x == 4) ans += 1ll << c, ++c;
else if(x == 5) ans += 1ll << c, c += 2;
else if(x == 6) ans += 1ll << (c + 1), c += 2;
else ans += (1ll << c) + (1ll << (c + 1)), c += 2;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
2508 KB |
Output is correct - L* = 40 |
2 |
Correct |
28 ms |
2572 KB |
Output is correct - L* = 40 |
3 |
Correct |
27 ms |
2552 KB |
Output is correct - L* = 40 |
4 |
Correct |
30 ms |
2560 KB |
Output is correct - L* = 40 |
5 |
Correct |
30 ms |
2568 KB |
Output is correct - L* = 40 |
6 |
Correct |
28 ms |
2468 KB |
Output is correct - L* = 40 |
7 |
Correct |
28 ms |
2508 KB |
Output is correct - L* = 40 |
8 |
Correct |
27 ms |
2504 KB |
Output is correct - L* = 40 |
9 |
Correct |
30 ms |
2472 KB |
Output is correct - L* = 40 |
10 |
Correct |
27 ms |
2512 KB |
Output is correct - L* = 40 |
11 |
Correct |
30 ms |
2608 KB |
Output is correct - L* = 40 |
12 |
Correct |
27 ms |
2568 KB |
Output is correct - L* = 40 |
13 |
Correct |
28 ms |
2532 KB |
Output is correct - L* = 40 |
14 |
Correct |
30 ms |
2652 KB |
Output is correct - L* = 40 |
15 |
Correct |
30 ms |
2508 KB |
Output is correct - L* = 40 |
16 |
Correct |
28 ms |
2480 KB |
Output is correct - L* = 40 |
17 |
Correct |
28 ms |
2476 KB |
Output is correct - L* = 40 |
18 |
Correct |
28 ms |
2548 KB |
Output is correct - L* = 40 |
19 |
Correct |
28 ms |
2588 KB |
Output is correct - L* = 40 |
20 |
Correct |
30 ms |
2560 KB |
Output is correct - L* = 40 |
21 |
Correct |
30 ms |
2580 KB |
Output is correct - L* = 40 |
22 |
Correct |
30 ms |
2500 KB |
Output is correct - L* = 40 |
23 |
Correct |
36 ms |
2624 KB |
Output is correct - L* = 40 |
24 |
Correct |
30 ms |
2476 KB |
Output is correct - L* = 40 |
25 |
Correct |
28 ms |
2460 KB |
Output is correct - L* = 40 |
26 |
Correct |
55 ms |
2504 KB |
Output is correct - L* = 40 |
27 |
Correct |
28 ms |
2484 KB |
Output is correct - L* = 40 |
28 |
Correct |
28 ms |
2544 KB |
Output is correct - L* = 40 |
29 |
Correct |
42 ms |
2460 KB |
Output is correct - L* = 40 |
30 |
Correct |
30 ms |
2612 KB |
Output is correct - L* = 40 |
31 |
Correct |
28 ms |
2556 KB |
Output is correct - L* = 40 |
32 |
Correct |
30 ms |
2508 KB |
Output is correct - L* = 40 |
33 |
Correct |
28 ms |
2500 KB |
Output is correct - L* = 40 |
34 |
Correct |
30 ms |
2532 KB |
Output is correct - L* = 40 |
35 |
Correct |
32 ms |
2524 KB |
Output is correct - L* = 40 |
36 |
Correct |
41 ms |
2404 KB |
Output is correct - L* = 40 |
37 |
Correct |
39 ms |
2512 KB |
Output is correct - L* = 40 |
38 |
Correct |
28 ms |
2428 KB |
Output is correct - L* = 40 |
39 |
Correct |
28 ms |
2592 KB |
Output is correct - L* = 40 |
40 |
Correct |
30 ms |
2480 KB |
Output is correct - L* = 40 |