# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1072368 | mickey080929 | Ancient Machine (JOI21_ancient_machine) | C++17 | 59 ms | 9828 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |