#include <bits/stdc++.h>
#include "Anna.h"
using namespace std;
void Anna(int N, std::vector<char> S) {
int firstX = N;
for(int i = 0 ; i < N ; i++){
if(S[i] == 'X'){
firstX = i;
break;
}
}
int lastZ = N;
for(int i = N - 1 ; i >= 0 ; i--){
if(S[i] == 'Z'){
lastZ = i;
break;
}
}
for(int i = 16 ; i >= 0 ; i--){
Send((firstX >> i) & 1);
}
for(int i = 16 ; i >= 0 ; i--){
Send((lastZ >> i) & 1);
}
vector <int> f(N);
for(int i = firstX + 1 ; i < lastZ ; i++){
if(S[i] == 'Y' && S[i - 1] != 'Y'){
f[i] = 1;
if(S[i - 1] == 'Z') f[i - 1] = 1;
}
}
for(int i = 0 ; i < N ; i++){
Send(f[i]);
}
}
#include <bits/stdc++.h>
#include "Bruno.h"
using namespace std;
void Bruno(int N, int L, std::vector<int> A) {
reverse(A.begin(), A.end());
auto get = [&](){
assert(A.size());
int x = A.back();
A.pop_back();
return x;
};
int firstX = 0;
for(int i = 0 ; i < 17 ; i++){
firstX = 2 * firstX + get();
}
int lastZ = 0;
for(int i = 0 ; i < 17 ; i++){
lastZ = 2 * lastZ + get();
}
if(firstX == N || lastZ == N){
for(int i = 0 ; i < N ; i++){
Remove(i);
}
return;
}
string S(N, ';');
S[firstX] = 'X';
S[lastZ] = 'Z';
vector <int> f(N);
for(int i = 0 ; i < N ; i++){
f[i] = get();
}
for(int i = lastZ - 1 ; i > firstX ; i--){
if(f[i]){
S[i] = 'Y';
if(f[i - 1]) S[i - 1] = 'Z';
else S[i - 1] = 'X';
i--;
}
}
for(int i = 0 ; i < N ; i++){
if(S[i] == ';') Remove(i);
}
vector <int> g;
for(int i = 0 ; i < N ; i++){
if(S[i] == ';') continue;
if(S[i] == 'X'){
if(g.size() && S[g.back()] == 'X'){
Remove(i);
}
else g.push_back(i);
}
else if(S[i] == 'Y'){
g.push_back(i);
}
else{
if(g.size() && S[g.back()] == 'X'){
Remove(i);
}
else{
while(g.size() > 1){
Remove(g.back());
g.pop_back();
}
Remove(i);
}
}
}
for(auto &i : g) Remove(i);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
764 KB |
Output is correct |
2 |
Correct |
1 ms |
488 KB |
Output is correct |
3 |
Correct |
1 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
1 ms |
488 KB |
Output is correct |
6 |
Correct |
1 ms |
508 KB |
Output is correct |
7 |
Correct |
2 ms |
488 KB |
Output is correct |
8 |
Correct |
1 ms |
500 KB |
Output is correct |
9 |
Correct |
1 ms |
500 KB |
Output is correct |
10 |
Correct |
1 ms |
500 KB |
Output is correct |
11 |
Correct |
1 ms |
496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
84 ms |
8648 KB |
Partially correct |
2 |
Partially correct |
71 ms |
8700 KB |
Partially correct |
3 |
Partially correct |
74 ms |
8676 KB |
Partially correct |
4 |
Partially correct |
72 ms |
8676 KB |
Partially correct |
5 |
Partially correct |
75 ms |
8604 KB |
Partially correct |
6 |
Partially correct |
73 ms |
8720 KB |
Partially correct |
7 |
Partially correct |
74 ms |
8640 KB |
Partially correct |
8 |
Partially correct |
81 ms |
8724 KB |
Partially correct |
9 |
Partially correct |
74 ms |
8624 KB |
Partially correct |
10 |
Partially correct |
72 ms |
8768 KB |
Partially correct |
11 |
Partially correct |
88 ms |
8696 KB |
Partially correct |
12 |
Partially correct |
73 ms |
8728 KB |
Partially correct |
13 |
Partially correct |
74 ms |
8944 KB |
Partially correct |
14 |
Partially correct |
72 ms |
8704 KB |
Partially correct |
15 |
Partially correct |
67 ms |
9072 KB |
Partially correct |
16 |
Partially correct |
65 ms |
8700 KB |
Partially correct |
17 |
Partially correct |
71 ms |
8464 KB |
Partially correct |
18 |
Partially correct |
77 ms |
8332 KB |
Partially correct |
19 |
Partially correct |
83 ms |
8436 KB |
Partially correct |
20 |
Partially correct |
68 ms |
8812 KB |
Partially correct |
21 |
Partially correct |
63 ms |
8796 KB |
Partially correct |
22 |
Partially correct |
77 ms |
8792 KB |
Partially correct |
23 |
Partially correct |
71 ms |
8596 KB |
Partially correct |
24 |
Partially correct |
68 ms |
8672 KB |
Partially correct |
25 |
Partially correct |
83 ms |
8380 KB |
Partially correct |
26 |
Partially correct |
74 ms |
8464 KB |
Partially correct |
27 |
Partially correct |
71 ms |
8776 KB |
Partially correct |
28 |
Partially correct |
72 ms |
8368 KB |
Partially correct |
29 |
Partially correct |
77 ms |
8336 KB |
Partially correct |
30 |
Partially correct |
71 ms |
8464 KB |
Partially correct |
31 |
Partially correct |
71 ms |
8444 KB |
Partially correct |
32 |
Partially correct |
69 ms |
8704 KB |
Partially correct |
33 |
Partially correct |
71 ms |
8720 KB |
Partially correct |