# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1151157 | ShadowShark | Ancient Machine (JOI21_ancient_machine) | C++20 | 0 ms | 0 KiB |
#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
void Anna(int N, std::vector<char> S) {
int firstX = -1;
for (int i = 0; i < N; i++) {
if (S[i] == 'X') {
firstX = i;
break;
}
}
for (int i = 1; i <= firstX; i++)
send(1);
send(0);
int pre = firstX;
for (int j = firstX + 1; j < N; j++) {
if (S[j] == 'Z') {
for (int k = 2; k <= j - pre; k++)
send(1);
send(0);
pre = j;
}
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
void Bruno(int N, int L, std::vector<int> A) {
bool mark[200005];
memset(mark, false, sizeof mark);
int firstX = 1;
for (int i = 0; i < L; i++)
if (A[i] == 1) firstX++;
else break;
int pre = firstX, cnt = 0;
for (int j = firstX; j < L; j++) {
if (A[j] == 1) cnt++;
else {
int nxt = pre + cnt + 1;
for (int i = nxt - 1; i >= pre && !mark[i]; i--) {
Remove(i - 1);
mark[i] = true;
}
pre = nxt;
}
}
for (int i = 1; i <= N; i++)
if (!mark[i]) {
mark[i] = true;
Remove(i - 1);
}
}