#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
void Send(int a);
void Remove(int d);
void mySend(vector<int> v) {
for (auto &x : v) {
Send(x);
}
}
void Anna(int N, vector<char> S) {
int x = -1, z = -1;
for (int i=0; i<N; i++) {
if (S[i] == 'X') {
x = i;
break;
}
}
for (int i=N-1; i>=0; i--) {
if (S[i] == 'Z') {
z = i;
break;
}
}
if (x == -1 || z == -1 || x > z) {
return;
}
for (int i=0; i<=16; i++) {
Send(bool(x & (1<<i)));
}
for (int i=0; i<=16; i++) {
Send(bool(z & (1<<i)));
}
vector<int> A;
for (int i=x; i<z; i++) {
if (S[i] == 'X') {
A.push_back(1);
i ++;
}
else {
A.push_back(0);
}
}
mySend(A);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
void Bruno(int N, int L, vector<int> A) {
if (L == 0) {
for (int i=0; i<N; i++) {
Remove(i);
}
return;
}
int x = 0, z = 0;
for (int i=0; i<=16; i++) {
if (A[i] == 1) {
x ^= (1<<i);
}
}
for (int i=0; i<=16; i++) {
if (A[i+17] == 1) {
z ^= (1<<i);
}
}
vector<int> v;
for (int i=34; i<L; i++) {
if (A[i]) {
v.push_back(1);
v.push_back(0);
}
else {
v.push_back(0);
}
}
while (v.size() > z - x) v.pop_back();
v.push_back(1);
vector<int> idx;
for (int i=0; i<v.size(); i++) {
if (v[i]) {
idx.push_back(i + x);
}
}
assert(idx[0] == x);
assert(idx.back() == z);
vector<int> chk(N, 0);
for (int i=0; i<idx[0]; i++) {
Remove(i);
chk[i] = 1;
}
for (int i=idx.back()+1; i<N; i++) {
Remove(i);
chk[i] = 1;
}
for (int i=0; i+1<idx.size(); i++) {
for (int j=idx[i]+1; j<=idx[i+1]-2; j++) {
Remove(j);
chk[j] = 1;
}
}
for (int i=idx.back()-1; i>=idx[0]; i--) {
if (!chk[i]) {
Remove(i);
}
}
Remove(idx.back());
}
Compilation message
Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:34:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
34 | while (v.size() > z - x) v.pop_back();
| ~~~~~~~~~^~~~~~~
Bruno.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for (int i=0; i<v.size(); i++) {
| ~^~~~~~~~~
Bruno.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for (int i=0; i+1<idx.size(); i++) {
| ~~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
776 KB |
Output is correct |
2 |
Correct |
1 ms |
784 KB |
Output is correct |
3 |
Correct |
0 ms |
796 KB |
Output is correct |
4 |
Correct |
0 ms |
784 KB |
Output is correct |
5 |
Correct |
0 ms |
796 KB |
Output is correct |
6 |
Correct |
0 ms |
780 KB |
Output is correct |
7 |
Correct |
0 ms |
796 KB |
Output is correct |
8 |
Correct |
0 ms |
784 KB |
Output is correct |
9 |
Correct |
0 ms |
796 KB |
Output is correct |
10 |
Correct |
1 ms |
796 KB |
Output is correct |
11 |
Correct |
0 ms |
784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
43 ms |
9100 KB |
Partially correct |
2 |
Partially correct |
40 ms |
9236 KB |
Partially correct |
3 |
Partially correct |
37 ms |
9320 KB |
Partially correct |
4 |
Partially correct |
59 ms |
9236 KB |
Partially correct |
5 |
Partially correct |
34 ms |
9312 KB |
Partially correct |
6 |
Partially correct |
51 ms |
9204 KB |
Partially correct |
7 |
Partially correct |
36 ms |
9236 KB |
Partially correct |
8 |
Partially correct |
48 ms |
9188 KB |
Partially correct |
9 |
Partially correct |
38 ms |
9152 KB |
Partially correct |
10 |
Partially correct |
35 ms |
9280 KB |
Partially correct |
11 |
Partially correct |
36 ms |
9320 KB |
Partially correct |
12 |
Partially correct |
37 ms |
9300 KB |
Partially correct |
13 |
Correct |
41 ms |
8696 KB |
Output is correct |
14 |
Partially correct |
45 ms |
9532 KB |
Partially correct |
15 |
Correct |
33 ms |
9396 KB |
Output is correct |
16 |
Correct |
48 ms |
9304 KB |
Output is correct |
17 |
Correct |
31 ms |
6908 KB |
Output is correct |
18 |
Correct |
32 ms |
6720 KB |
Output is correct |
19 |
Correct |
33 ms |
7236 KB |
Output is correct |
20 |
Partially correct |
41 ms |
9204 KB |
Partially correct |
21 |
Partially correct |
37 ms |
9244 KB |
Partially correct |
22 |
Partially correct |
43 ms |
9828 KB |
Partially correct |
23 |
Partially correct |
41 ms |
9296 KB |
Partially correct |
24 |
Partially correct |
37 ms |
9216 KB |
Partially correct |
25 |
Correct |
37 ms |
6932 KB |
Output is correct |
26 |
Correct |
31 ms |
6904 KB |
Output is correct |
27 |
Correct |
31 ms |
6980 KB |
Output is correct |
28 |
Correct |
30 ms |
6956 KB |
Output is correct |
29 |
Correct |
36 ms |
6780 KB |
Output is correct |
30 |
Correct |
33 ms |
6868 KB |
Output is correct |
31 |
Correct |
39 ms |
6900 KB |
Output is correct |
32 |
Partially correct |
38 ms |
9288 KB |
Partially correct |
33 |
Partially correct |
37 ms |
9424 KB |
Partially correct |