#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;
// 1 ---- > 0
// 2 ---- > 1
// 5 ---- > 1
// 3 ---- > 10
// 4 ---- > 00
// 6 ---- > 01
// 7 ---- > 11
void assign(int idx, int val) {
if (val >= 4) Set(idx, 1), val -= 4; else Set(idx, 0);
if (val >= 2) Set(idx + 1, 1), val -= 2; else Set(idx + 1, 0);
if (val >= 1) Set(idx + 2, 1), val -= 1; else Set(idx + 2, 0);
}
void Anna( int N, long long X, int K, int P[] ){
std::vector <int> bit, fix;
bit = vector <int> (65, 0);
fix = vector <int> (155, 0);
for (int i = 0; i < 60; i++) {
bit[i] = ((1LL<<i)&X ? 1 : 0);
}
for (int i = 0; i < K; i++) {
fix[P[i]] = 1;
}
int cur = 0;
for (int i = 0; i < 150; i+=3) {
if (cur >= 60) {
for (int j = i; j < 150; j+=3) {
assign(j, 0);
}
break;
}
int bl = fix[i] + fix[i + 1] + fix[i + 2];
if (bl >= 2) {
assign(i, 0);
continue;
}
if (bl == 0) {
int val = bit[cur] * 2 + bit[cur + 1];
// cout<<cur<<" "<<bit[cur]<<" "<<bit[cur + 1]<<"\n";
cur += 2;
if (val == 3) {
assign(i, 7); continue;
}
if (val == 0) {
assign(i, 4); continue;
}
if (val == 1) {
assign(i, 6); continue;
}
if (val == 2) {
assign(i, 3); continue;
}
// cout<<bl<<" "<<val<<"\n";
}
assert(bl == 1);
int val = bit[cur];
if (!fix[i + 2] && val == 0) {
cur++; assign(i, 1); continue;
}
if (!fix[i + 1] && val == 1) {
cur++; assign(i, 2); continue;
}
int val1 = bit[cur + 1];
if (val == 0) { // i da i + 1 emp
if (val1 == 0) {
assign(i, 4); cur += 2; continue;
}
if (val1 == 1) {
assign(i, 6); cur += 2; continue;
}
}
// i da i + 2 emp
if (val == 1) {
assign(i, 5); cur++; continue;
}
}
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
// 1 ---- > 0
// 2 ---- > 1
// 5 ---- > 1
// 3 ---- > 10
// 4 ---- > 00
// 6 ---- > 01
// 7 ---- > 11
long long Bruno( int N, int A[] ){
string get[10];
get[0] = "";
get[1] = "0";
get[2] = "1";
get[5] = "1";
get[3] = "10";
get[4] = "00";
get[6] = "01";
get[7] = "11";
string ans = "";
for (int i = 0; i < 150; i += 3) {
int x = A[i] * 4 + A[i + 1] * 2 + A[i + 2];
ans += get[x];
}
long long res = 0;
for (int i = 0; i < ans.size(); i++) {
res += (ans[i] == '1' ? (1LL<<i) : 0);
}
return res;
}
Compilation message
Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:32:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for (int i = 0; i < ans.size(); i++) {
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
2432 KB |
Output is correct - L* = 40 |
2 |
Correct |
28 ms |
2528 KB |
Output is correct - L* = 40 |
3 |
Correct |
28 ms |
2484 KB |
Output is correct - L* = 40 |
4 |
Correct |
30 ms |
2588 KB |
Output is correct - L* = 40 |
5 |
Correct |
28 ms |
2536 KB |
Output is correct - L* = 40 |
6 |
Correct |
28 ms |
2428 KB |
Output is correct - L* = 40 |
7 |
Correct |
28 ms |
2392 KB |
Output is correct - L* = 40 |
8 |
Correct |
28 ms |
2460 KB |
Output is correct - L* = 40 |
9 |
Correct |
28 ms |
2460 KB |
Output is correct - L* = 40 |
10 |
Correct |
28 ms |
2476 KB |
Output is correct - L* = 40 |
11 |
Correct |
28 ms |
2464 KB |
Output is correct - L* = 40 |
12 |
Correct |
28 ms |
2504 KB |
Output is correct - L* = 40 |
13 |
Correct |
28 ms |
2448 KB |
Output is correct - L* = 40 |
14 |
Correct |
28 ms |
2432 KB |
Output is correct - L* = 40 |
15 |
Correct |
29 ms |
2560 KB |
Output is correct - L* = 40 |
16 |
Correct |
28 ms |
2420 KB |
Output is correct - L* = 40 |
17 |
Correct |
28 ms |
2452 KB |
Output is correct - L* = 40 |
18 |
Correct |
33 ms |
2388 KB |
Output is correct - L* = 40 |
19 |
Correct |
28 ms |
2488 KB |
Output is correct - L* = 40 |
20 |
Correct |
30 ms |
2376 KB |
Output is correct - L* = 40 |
21 |
Correct |
28 ms |
2472 KB |
Output is correct - L* = 40 |
22 |
Correct |
30 ms |
2464 KB |
Output is correct - L* = 40 |
23 |
Correct |
28 ms |
2480 KB |
Output is correct - L* = 40 |
24 |
Correct |
28 ms |
2476 KB |
Output is correct - L* = 40 |
25 |
Correct |
28 ms |
2428 KB |
Output is correct - L* = 40 |
26 |
Correct |
41 ms |
2436 KB |
Output is correct - L* = 40 |
27 |
Correct |
40 ms |
2456 KB |
Output is correct - L* = 40 |
28 |
Correct |
40 ms |
2420 KB |
Output is correct - L* = 40 |
29 |
Correct |
28 ms |
2420 KB |
Output is correct - L* = 40 |
30 |
Correct |
56 ms |
2572 KB |
Output is correct - L* = 40 |
31 |
Correct |
42 ms |
2572 KB |
Output is correct - L* = 40 |
32 |
Correct |
50 ms |
2416 KB |
Output is correct - L* = 40 |
33 |
Correct |
41 ms |
2500 KB |
Output is correct - L* = 40 |
34 |
Correct |
32 ms |
2568 KB |
Output is correct - L* = 40 |
35 |
Correct |
30 ms |
2532 KB |
Output is correct - L* = 40 |
36 |
Correct |
31 ms |
2444 KB |
Output is correct - L* = 40 |
37 |
Correct |
40 ms |
2488 KB |
Output is correct - L* = 40 |
38 |
Correct |
40 ms |
2456 KB |
Output is correct - L* = 40 |
39 |
Correct |
34 ms |
2508 KB |
Output is correct - L* = 40 |
40 |
Correct |
38 ms |
2540 KB |
Output is correct - L* = 40 |