#include <vector>
using namespace std;
void Anna(int N, std::vector<char> S);
void Send(int a);
void Anna(int N, std::vector<char> S) {
int cnt[3] = {0};
for (char x: S) {
if (x == 'X') ++cnt[0];
if (x == 'Y') ++cnt[1];
if (x == 'Z') ++cnt[2];
}
vector<char> order;
if (cnt[0] >= cnt[1] && cnt[0] >= cnt[2]) {
order.push_back('X');
order.push_back('Y');
order.push_back('Z');
Send(0); Send(0);
} else if (cnt[1] >= cnt[0] && cnt[1] >= cnt[2]) {
order.push_back('Y');
order.push_back('X');
order.push_back('Z');
Send(0); Send(1);
} else {
order.push_back('Z');
order.push_back('X');
order.push_back('Y');
Send(1); Send(1);
}
for (char x: S) {
if (x == order[0])
Send(1);
else
Send(0);
}
for (char x: S) {
if (x != order[0])
if (x == order[1])
Send(0);
else
Send(1);
}
}
#include <deque>
#include <vector>
#include <iostream>
using namespace std;
void Bruno(int N, int L, std::vector<int> A);
void Remove(int d);
// 11 XYZXZYXYXYZ
void Bruno(int N, int L, std::vector<int> A) {
vector<char> order;
if (A[0] + A[1] == 0) {
order.push_back('X');
order.push_back('Y');
order.push_back('Z');
}
if (A[0] + A[1] == 1) {
order.push_back('Y');
order.push_back('X');
order.push_back('Z');
}
if (A[0] + A[1] == 2) {
order.push_back('Z');
order.push_back('X');
order.push_back('Y');
}
int ptr = 1;
vector<char> S;
for (int i = 0; i < N; ++i)
S.push_back('0');
for (int i = 0; i < N; ++i) {
++ptr;
if (A[ptr] == 1)
S[i] = order[0];
}
for (int i = 0; i < N; ++i) if (S[i] == '0') {
++ptr;
S[i] = order[A[ptr] + 1];
}
deque<int> d;
for (int i = N - 1; i >= 0; --i) {
if (d.empty()) {
if (S[i] == 'Z') d.push_back(i); else Remove(i);
} else {
if (S[i] == 'Y') {
if (S[d.front()] == 'Z')
d.push_front(i);
else Remove(i);
} else if (S[i] == 'X') {
while (d.size() >= 2) {
while (d.size() > 1 && S[d.front() == 'Z']) {
Remove(d.front()); d.pop_front();
}
if (S[d[0]] == 'Y' && S[d[1]] == 'Z') {
Remove(d[0]); d.pop_front();
if (d.size() > 1) Remove(d[0]), d.pop_front();
} else break;
} Remove(i);
} else d.push_front(i);
}
}
while (!d.empty()) {
Remove(d[0]); d.pop_front();
}
}
Compilation message
Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:44:12: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
44 | if (x != order[0])
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
776 KB |
Output is correct |
2 |
Correct |
0 ms |
772 KB |
Output is correct |
3 |
Correct |
0 ms |
780 KB |
Output is correct |
4 |
Correct |
0 ms |
792 KB |
Output is correct |
5 |
Correct |
0 ms |
788 KB |
Output is correct |
6 |
Correct |
0 ms |
792 KB |
Output is correct |
7 |
Correct |
1 ms |
788 KB |
Output is correct |
8 |
Correct |
0 ms |
780 KB |
Output is correct |
9 |
Correct |
0 ms |
792 KB |
Output is correct |
10 |
Correct |
0 ms |
780 KB |
Output is correct |
11 |
Correct |
0 ms |
780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
59 ms |
8928 KB |
Partially correct |
2 |
Partially correct |
55 ms |
8964 KB |
Partially correct |
3 |
Partially correct |
51 ms |
8964 KB |
Partially correct |
4 |
Partially correct |
51 ms |
9012 KB |
Partially correct |
5 |
Partially correct |
52 ms |
8944 KB |
Partially correct |
6 |
Partially correct |
53 ms |
8988 KB |
Partially correct |
7 |
Partially correct |
58 ms |
9000 KB |
Partially correct |
8 |
Partially correct |
53 ms |
8896 KB |
Partially correct |
9 |
Partially correct |
57 ms |
8916 KB |
Partially correct |
10 |
Partially correct |
55 ms |
8936 KB |
Partially correct |
11 |
Partially correct |
52 ms |
8968 KB |
Partially correct |
12 |
Partially correct |
52 ms |
8944 KB |
Partially correct |
13 |
Partially correct |
56 ms |
8744 KB |
Partially correct |
14 |
Partially correct |
46 ms |
8736 KB |
Partially correct |
15 |
Partially correct |
54 ms |
8952 KB |
Partially correct |
16 |
Partially correct |
57 ms |
8908 KB |
Partially correct |
17 |
Partially correct |
46 ms |
7956 KB |
Partially correct |
18 |
Partially correct |
47 ms |
7792 KB |
Partially correct |
19 |
Partially correct |
40 ms |
7820 KB |
Partially correct |
20 |
Partially correct |
49 ms |
8748 KB |
Partially correct |
21 |
Partially correct |
48 ms |
8744 KB |
Partially correct |
22 |
Partially correct |
46 ms |
7912 KB |
Partially correct |
23 |
Partially correct |
53 ms |
9020 KB |
Partially correct |
24 |
Partially correct |
50 ms |
9028 KB |
Partially correct |
25 |
Partially correct |
48 ms |
7836 KB |
Partially correct |
26 |
Partially correct |
55 ms |
7812 KB |
Partially correct |
27 |
Partially correct |
46 ms |
7800 KB |
Partially correct |
28 |
Partially correct |
46 ms |
7904 KB |
Partially correct |
29 |
Partially correct |
45 ms |
7884 KB |
Partially correct |
30 |
Partially correct |
47 ms |
7808 KB |
Partially correct |
31 |
Partially correct |
54 ms |
7720 KB |
Partially correct |
32 |
Partially correct |
52 ms |
8744 KB |
Partially correct |
33 |
Partially correct |
59 ms |
8732 KB |
Partially correct |