#include "Anna.h"
#include <vector>
namespace {
int variable_example = 0;
}
void Anna(int N, std::vector<char> S) {
for (int i = 0; i < N; i++) {
if (S[i] == 'X') {
Send(0);
} else if (S[i] == 'Y') {
Send(1);
Send(0);
} else {
Send(1);
Send(1);
}
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
void resolve(vector<int> &ord, vector<vector<int>> &dp,
vector<vector<int>> &par, int l, int r) {
if (l > r)
return;
if (l == r) {
ord.push_back(l);
return;
}
if (par[l][r] >= 0) {
resolve(ord, dp, par, l, par[l][r]);
resolve(ord, dp, par, par[l][r] + 1, r);
} else {
resolve(ord, dp, par, l, ~par[l][r] - 1);
resolve(ord, dp, par, ~par[l][r] + 1, r);
ord.push_back(~par[l][r]);
}
}
} // namespace
void Bruno(int N, int L, std::vector<int> A) {
string target;
int ptr = 0;
while (ptr < L) {
if (A[ptr++] == 0)
target.push_back('X');
else if (A[ptr++] == 0)
target.push_back('Y');
else
target.push_back('Z');
}
vector<vector<int>> g(N);
for (int i = 0; i < N; i++) {
if (target[i] != 'Y')
continue;
int x = -1;
for (int j = i - 1; j >= 0; j--) {
if (target[j] == 'X') {
x = j;
break;
}
}
int z = N;
for (int j = i + 1; j < N; j++) {
if (target[j] == 'Z') {
z = j;
break;
}
}
if (x == -1 || z == N)
continue;
for (int j = x + 1; j < z; j++) {
if (j == i)
continue;
g[j].push_back(i);
}
}
vector<vector<int>> dp(N);
vector<vector<int>> par(N);
for (int i = 0; i < N; i++) {
dp[i].resize(N, 0);
par[i].resize(N, 0);
dp[i][i] = 0;
par[i][i] = i;
}
for (int itv = 1; itv < N; itv++) {
for (int i = 0; i + itv < N; i++) {
int j = i + itv;
dp[i][j] = -1;
if (i > 0 && j + 1 < N && target[i - 1] == 'X' &&
target[j + 1] == 'Z') {
for (int k = i; k <= j; k++) {
if (target[k] == 'Y') {
if (dp[i][k - 1] + dp[k + 1][j] + 1 > dp[i][j]) {
dp[i][j] = dp[i][k - 1] + dp[k + 1][j] + 1;
par[i][j] = ~k;
}
}
}
}
for (int k = i; k < j; k++) {
if (dp[i][k] + dp[k + 1][j] > dp[i][j]) {
dp[i][j] = dp[i][k] + dp[k + 1][j];
par[i][j] = k;
}
}
}
}
vector<int> ord;
resolve(ord, dp, par, 0, N - 1);
for (int x : ord)
Remove(x);
}
Compilation message
Anna.cpp:6:5: warning: '{anonymous}::variable_example' defined but not used [-Wunused-variable]
6 | int variable_example = 0;
| ^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
792 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
121 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |