#include "Annalib.h"
#include <vector>
#include <iostream>
#include <string>
using namespace std;
namespace
{
using vi = vector<int>;
using ll = long long;
#define sz(x) int(x.size())
vector<string> key = vector<string>{string{""}, string{"0"}, string{"1"}, string{"00"}, string{"10"}, string{"11"}, string{"0"}, string{"01"}};
}
void Anna(int N, ll X, int K, int P[])
{
string bs(200, '0');
for(int b = 0; b < 200; b++)
{
bs[b] = (X%2) + '0';
X >>= 1;
}
vi br(N, 0); //broken
for(int i = 0; i < K; i++)
br[P[i]] = 1;
int cb = 0;
// cerr << "N = " << N << '\n';
for(int i = 0; i < N; i += 3)
{
// cerr << "i = " << i << "\n";
int cbr = br[i] + 2*br[i+1] + 4*br[i+2];
for(int b2 : {3, 4, 5, 7, 1, 2, 6, 0})
{
bool valid = 1;
// cerr << "cbr = " << cbr << ", cb = " << cb << '\n';
// cerr << bs[cb] << ' ' << bs[cb+1] << '\n';
for(int f = 0; f < sz(key[b2]); f++)
if(key[b2][f] != bs[cb+f])
valid = 0;
if(!valid) continue;
// cerr << "going for " << b2 << '\n';
if((b2 & cbr) == 0)
{
cb += sz(key[b2]);
for(int j = 0; j < 3; j++)
{
// cerr << "set : " << i+j << '\n';
Set(i + j, (b2 >> j) & 1);
}
break;
}
}
}
// cerr << "terminated\n";
}
#include "Brunolib.h"
#include <vector>
#include <string>
using namespace std;
namespace
{
using vi = vector<int>;
using ll = long long;
#define sz(x) int(x.size())
vector<string> key = vector<string>{string{""}, string{"0"}, string{"1"}, string{"00"}, string{"10"}, string{"11"}, string{"0"}, string{"01"}};
}
ll Bruno(int N, int A[])
{
string res_s;
for(int i = 0; i < N; i += 3)
{
int z = A[i] + 2*A[i+1] + 4*A[i+2];
res_s += key[z];
}
ll bs = 1;
ll res = 0;
for(int i = 0; i < 60; i++)
{
if(res_s[i] == '1')
res += bs;
bs *= 2;
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
2248 KB |
Output is correct - L* = 40 |
2 |
Correct |
40 ms |
2296 KB |
Output is correct - L* = 40 |
3 |
Correct |
32 ms |
2352 KB |
Output is correct - L* = 40 |
4 |
Correct |
32 ms |
2232 KB |
Output is correct - L* = 40 |
5 |
Correct |
35 ms |
2228 KB |
Output is correct - L* = 40 |
6 |
Correct |
40 ms |
2256 KB |
Output is correct - L* = 40 |
7 |
Correct |
35 ms |
2296 KB |
Output is correct - L* = 40 |
8 |
Correct |
36 ms |
2328 KB |
Output is correct - L* = 40 |
9 |
Correct |
36 ms |
2304 KB |
Output is correct - L* = 40 |
10 |
Correct |
33 ms |
2280 KB |
Output is correct - L* = 40 |
11 |
Correct |
32 ms |
2248 KB |
Output is correct - L* = 40 |
12 |
Correct |
32 ms |
2324 KB |
Output is correct - L* = 40 |
13 |
Correct |
34 ms |
2228 KB |
Output is correct - L* = 40 |
14 |
Correct |
37 ms |
2256 KB |
Output is correct - L* = 40 |
15 |
Correct |
37 ms |
2264 KB |
Output is correct - L* = 40 |
16 |
Correct |
38 ms |
2264 KB |
Output is correct - L* = 40 |
17 |
Correct |
35 ms |
2232 KB |
Output is correct - L* = 40 |
18 |
Correct |
32 ms |
2300 KB |
Output is correct - L* = 40 |
19 |
Correct |
35 ms |
2376 KB |
Output is correct - L* = 40 |
20 |
Correct |
34 ms |
2264 KB |
Output is correct - L* = 40 |
21 |
Correct |
34 ms |
2276 KB |
Output is correct - L* = 40 |
22 |
Correct |
34 ms |
2248 KB |
Output is correct - L* = 40 |
23 |
Correct |
35 ms |
2248 KB |
Output is correct - L* = 40 |
24 |
Correct |
33 ms |
2368 KB |
Output is correct - L* = 40 |
25 |
Correct |
33 ms |
2260 KB |
Output is correct - L* = 40 |
26 |
Correct |
33 ms |
2264 KB |
Output is correct - L* = 40 |
27 |
Correct |
34 ms |
2232 KB |
Output is correct - L* = 40 |
28 |
Correct |
35 ms |
2284 KB |
Output is correct - L* = 40 |
29 |
Correct |
40 ms |
2252 KB |
Output is correct - L* = 40 |
30 |
Correct |
36 ms |
2268 KB |
Output is correct - L* = 40 |
31 |
Correct |
37 ms |
2228 KB |
Output is correct - L* = 40 |
32 |
Correct |
34 ms |
2228 KB |
Output is correct - L* = 40 |
33 |
Correct |
34 ms |
2248 KB |
Output is correct - L* = 40 |
34 |
Correct |
32 ms |
2288 KB |
Output is correct - L* = 40 |
35 |
Correct |
36 ms |
2280 KB |
Output is correct - L* = 40 |
36 |
Correct |
39 ms |
2256 KB |
Output is correct - L* = 40 |
37 |
Correct |
34 ms |
2288 KB |
Output is correct - L* = 40 |
38 |
Correct |
41 ms |
2336 KB |
Output is correct - L* = 40 |
39 |
Correct |
32 ms |
2248 KB |
Output is correct - L* = 40 |
40 |
Correct |
33 ms |
2372 KB |
Output is correct - L* = 40 |