#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) {
vector<int> A(N, 0);
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) {
mySend(A);
return;
}
A[x] = 1;
A[z] = 1;
for (int i=x; i<=z; i++) {
if (S[i] == 'X') {
A[i] = 1;
}
}
mySend(A);
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
void Send(int a);
void Remove(int d);
void Bruno(int N, int L, vector<int> A) {
vector<int> idx;
for (int i=0; i<L; i++) {
if (A[i]) {
idx.push_back(i);
}
}
if (idx.empty()) {
for (int i=0; i<N; i++) {
Remove(i);
}
return;
}
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:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for (int i=0; i+1<idx.size(); i++) {
| ~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
788 KB |
Output is correct |
2 |
Correct |
0 ms |
792 KB |
Output is correct |
3 |
Correct |
0 ms |
796 KB |
Output is correct |
4 |
Correct |
1 ms |
780 KB |
Output is correct |
5 |
Correct |
0 ms |
780 KB |
Output is correct |
6 |
Correct |
0 ms |
780 KB |
Output is correct |
7 |
Correct |
0 ms |
780 KB |
Output is correct |
8 |
Correct |
0 ms |
780 KB |
Output is correct |
9 |
Correct |
1 ms |
780 KB |
Output is correct |
10 |
Correct |
0 ms |
792 KB |
Output is correct |
11 |
Correct |
1 ms |
792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
45 ms |
8964 KB |
Partially correct |
2 |
Partially correct |
41 ms |
8968 KB |
Partially correct |
3 |
Partially correct |
44 ms |
8908 KB |
Partially correct |
4 |
Partially correct |
41 ms |
8912 KB |
Partially correct |
5 |
Partially correct |
45 ms |
8832 KB |
Partially correct |
6 |
Partially correct |
41 ms |
8868 KB |
Partially correct |
7 |
Partially correct |
40 ms |
8936 KB |
Partially correct |
8 |
Partially correct |
41 ms |
8916 KB |
Partially correct |
9 |
Partially correct |
39 ms |
8836 KB |
Partially correct |
10 |
Partially correct |
38 ms |
8920 KB |
Partially correct |
11 |
Partially correct |
51 ms |
8836 KB |
Partially correct |
12 |
Partially correct |
41 ms |
8832 KB |
Partially correct |
13 |
Partially correct |
45 ms |
9060 KB |
Partially correct |
14 |
Partially correct |
42 ms |
8664 KB |
Partially correct |
15 |
Partially correct |
38 ms |
8832 KB |
Partially correct |
16 |
Partially correct |
42 ms |
8832 KB |
Partially correct |
17 |
Partially correct |
45 ms |
8676 KB |
Partially correct |
18 |
Partially correct |
42 ms |
8676 KB |
Partially correct |
19 |
Partially correct |
43 ms |
8784 KB |
Partially correct |
20 |
Partially correct |
38 ms |
8860 KB |
Partially correct |
21 |
Partially correct |
45 ms |
8984 KB |
Partially correct |
22 |
Partially correct |
41 ms |
8912 KB |
Partially correct |
23 |
Partially correct |
40 ms |
8828 KB |
Partially correct |
24 |
Partially correct |
40 ms |
8904 KB |
Partially correct |
25 |
Partially correct |
44 ms |
8936 KB |
Partially correct |
26 |
Partially correct |
48 ms |
8560 KB |
Partially correct |
27 |
Partially correct |
43 ms |
8700 KB |
Partially correct |
28 |
Partially correct |
43 ms |
8664 KB |
Partially correct |
29 |
Partially correct |
42 ms |
8580 KB |
Partially correct |
30 |
Partially correct |
47 ms |
8692 KB |
Partially correct |
31 |
Partially correct |
43 ms |
8552 KB |
Partially correct |
32 |
Partially correct |
41 ms |
8932 KB |
Partially correct |
33 |
Partially correct |
40 ms |
8848 KB |
Partially correct |