#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
void send(int x) {
bitset<17> a(x);
for (int i = 0; i < 17; i++) Send(a[i]);
}
int f[1 << 18];
int trace[1 << 18];
void Anna(int N, std::vector<char> S) {
string temp = "XYZ";
memset(f, -1, sizeof f);
f[0] = 0;
trace[0] = -1;
for (int i = 0; i < 1 << N; i++) {
for (int j = 0; j < N; j++) {
if (i >> j & 1 ^ 1) {
bool okl = 0, okr = 0, okm = S[j] == 'Y';
for (int k = j - 1; k >= 0; k--) {
if (i >> k & 1 ^ 1) {
okl = S[k] == 'X';
break;
}
}
for (int k = j + 1; k < N; k++) {
if (i >> k & 1 ^ 1) {
okr = S[k] == 'Z';
break;
}
}
if (f[i | (1 << j)] < f[i] + (okl && okr && okm)) {
f[i | (1 << j)] = f[i] + (okl && okr && okm);
trace[i | (1 << j)] = j;
}
}
}
}
int cur = (1 << N) - 1;
vector<int> ans;
while (trace[cur] != -1) {
cerr << cur << ' ';
ans.emplace_back(trace[cur]);
cur ^= 1 << trace[cur];
}
reverse(ans.begin(), ans.end());
for (int x : ans) send(x);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
void Bruno(int N, int L, std::vector<int> A) {
for (int i = 0; i < L; i += 17) {
int pos = 0;
for (int j = i; j < i + 17; j++) {
if (A[j]) pos |= 1 << (j - i);
}
Remove(pos);
}
}
Compilation message
Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:21:36: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
21 | if (i >> j & 1 ^ 1) {
| ~~~~~~~^~~
Anna.cpp:24:52: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
24 | if (i >> k & 1 ^ 1) {
| ~~~~~~~^~~
Anna.cpp:30:52: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
30 | if (i >> k & 1 ^ 1) {
| ~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
2560 KB |
Output is correct |
2 |
Correct |
29 ms |
2656 KB |
Output is correct |
3 |
Correct |
31 ms |
2536 KB |
Output is correct |
4 |
Correct |
31 ms |
2564 KB |
Output is correct |
5 |
Correct |
28 ms |
2616 KB |
Output is correct |
6 |
Correct |
31 ms |
2620 KB |
Output is correct |
7 |
Correct |
1 ms |
1536 KB |
Output is correct |
8 |
Correct |
1 ms |
1536 KB |
Output is correct |
9 |
Correct |
29 ms |
2576 KB |
Output is correct |
10 |
Correct |
31 ms |
2456 KB |
Output is correct |
11 |
Correct |
27 ms |
2624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
2964 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |