#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
#define sz(s) (int(s.size()))
void Anna(int n, vector<char> S) {
vector<int> conv;
int p = 1;
for (int i = 0; i < n && S[i] != 'X'; i++) S[i] = 'Y';
int r = n-1;
for (; r >= 0 && S[r] != 'Z'; r--) S[r] = 'Y';
if (r < 2) return;
for (int i = r-1; i > 0 && S[i] != 'Y'; i--) S[i] = 'X';
for (char c: S) {
int v = c-'X';
if ((v&1)==(p&1)) conv.push_back(1);
else {
conv.push_back(v);
p = v;
}
}
conv.resize(r);
conv.push_back(1);
vector<int> gold_code; // 0 -> XY, 1 -> ZY, 2 -> YXY
for (int i = 0; i < sz(conv);) {
if (conv[i] != 1) {
assert(i < sz(conv)-1);
assert(conv[i+1] == 1);
gold_code.push_back(conv[i]/2);
i += 2;
}
else {
if (i == sz(conv)-1) break;
if (conv[i+1] == 1) {
conv[i] = 2;
gold_code.push_back(1);
i += 2;
}
else if (conv[i+1] == 2) {
swap(conv[i], conv[i+1]);
gold_code.push_back(1);
i += 2;
}
else {
assert(i < sz(conv)-2);
assert(conv[i+2] == 1);
gold_code.push_back(2);
i += 3;
}
}
}
bool ex = (conv.end()[-2] == 1);
if (ex) conv.pop_back();
for (int i = 0; i < sz(conv); i++) {
if (conv[i] == 1) Send(0);
else {
Send(1);
Send(conv[i] == 2);
i++;
}
}
Send(ex);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
#define sz(s) (int(s.size()))
void Bruno(int n, int l, vector<int> A) {
if (sz(A) == 0) {
for (int i = 0; i < n; i++) Remove(i);
return;
}
vector<int> tp;
set<int> xz, y;
for (int i = 0; i < l-1; i++) {
if (A[i] == 0) tp.push_back(1);
else {
i++;
tp.push_back(2*A[i]);
tp.push_back(1);
}
}
int r = sz(tp)-1 + A[l-1];
if (A[l-1]) tp.push_back(2);
else tp[r] = 2;
while (sz(tp) < n) tp.push_back(1);
for (int i = 0; i < n; i++) {
if (tp[i]&1) y.insert(i);
else xz.insert(i);
}
auto del = [&](int v) {
if (tp[v]&1) {
if (y.find(v) == y.end()) return;
y.erase(v);
}
else {
if (xz.find(v) == xz.end()) return;
xz.erase(v);
}
Remove(v);
};
if (sz(xz) > 1) {
int lim = *(xz.begin());
for (int s = *(xz.begin()); s != *(xz.rbegin()); ) {
int nxt = *(xz.upper_bound(s));
if (nxt == r) break;
if (tp[nxt] == 0) {
s = nxt;
lim = nxt;
continue;
}
for (int i = lim+1; i <= nxt; i++) del(i);
lim = nxt;
}
int s = *(xz.rbegin());
lim = s;
while (sz(xz) > 1) {
int p = *(--xz.find(s));
for (int i = p+1; i < lim; i++) del(i);
del(p);
lim = p;
}
}
for (int i = 0; i < n; i++) del(i);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
784 KB |
Output is correct |
2 |
Correct |
0 ms |
800 KB |
Output is correct |
3 |
Correct |
1 ms |
796 KB |
Output is correct |
4 |
Correct |
1 ms |
796 KB |
Output is correct |
5 |
Correct |
0 ms |
796 KB |
Output is correct |
6 |
Correct |
1 ms |
788 KB |
Output is correct |
7 |
Correct |
1 ms |
784 KB |
Output is correct |
8 |
Correct |
1 ms |
1012 KB |
Output is correct |
9 |
Correct |
1 ms |
784 KB |
Output is correct |
10 |
Correct |
1 ms |
780 KB |
Output is correct |
11 |
Correct |
0 ms |
780 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
56 ms |
9780 KB |
Partially correct |
2 |
Partially correct |
54 ms |
9520 KB |
Partially correct |
3 |
Partially correct |
56 ms |
9532 KB |
Partially correct |
4 |
Partially correct |
54 ms |
9520 KB |
Partially correct |
5 |
Partially correct |
55 ms |
9536 KB |
Partially correct |
6 |
Partially correct |
54 ms |
9784 KB |
Partially correct |
7 |
Partially correct |
55 ms |
9580 KB |
Partially correct |
8 |
Partially correct |
53 ms |
9524 KB |
Partially correct |
9 |
Partially correct |
59 ms |
9576 KB |
Partially correct |
10 |
Partially correct |
54 ms |
9568 KB |
Partially correct |
11 |
Partially correct |
54 ms |
9548 KB |
Partially correct |
12 |
Partially correct |
63 ms |
9520 KB |
Partially correct |
13 |
Partially correct |
62 ms |
9652 KB |
Partially correct |
14 |
Partially correct |
62 ms |
9532 KB |
Partially correct |
15 |
Partially correct |
60 ms |
9532 KB |
Partially correct |
16 |
Partially correct |
63 ms |
9532 KB |
Partially correct |
17 |
Correct |
31 ms |
6988 KB |
Output is correct |
18 |
Correct |
32 ms |
6960 KB |
Output is correct |
19 |
Correct |
32 ms |
6836 KB |
Output is correct |
20 |
Partially correct |
60 ms |
9620 KB |
Partially correct |
21 |
Partially correct |
60 ms |
9520 KB |
Partially correct |
22 |
Partially correct |
61 ms |
9524 KB |
Partially correct |
23 |
Partially correct |
52 ms |
9760 KB |
Partially correct |
24 |
Partially correct |
53 ms |
9764 KB |
Partially correct |
25 |
Correct |
31 ms |
6988 KB |
Output is correct |
26 |
Correct |
33 ms |
6984 KB |
Output is correct |
27 |
Correct |
31 ms |
6924 KB |
Output is correct |
28 |
Correct |
33 ms |
6896 KB |
Output is correct |
29 |
Correct |
32 ms |
6988 KB |
Output is correct |
30 |
Correct |
35 ms |
6900 KB |
Output is correct |
31 |
Correct |
31 ms |
6864 KB |
Output is correct |
32 |
Partially correct |
54 ms |
9520 KB |
Partially correct |
33 |
Partially correct |
58 ms |
9660 KB |
Partially correct |