# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
417306 | tqbfjotld | Ancient Machine (JOI21_ancient_machine) | C++17 | 102 ms | 8572 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 <vector>
#include <string>
using namespace std;
///log_3(2^N) +17 bits?
void Anna(int N, std::vector<char> S) {
int Xpos = -1;
int Zpos = -1;
for (int x = 0; x<N; x++){
if (S[x]=='Z') Zpos = x;
if (Xpos==-1 && S[x]=='X') Xpos = x;
}
for (int x = 16; x>=0; x--){
Send((bool)(Xpos&(1<<x)));
}
while (S.size()%58!=(Xpos+1)%58){
S.push_back('X');
}
for (int x = Xpos+1; x<N; x+=29){
long long state = 0;
for (int y = 0; y<58; y+=2){
string t = "";
t.push_back(S[x+y]);
t.push_back(S[x+y+1]);
vector<string> opt0 = {"XX","XY","YX","YY"};
vector<string> opt1 = {"XZ","YZ","ZZ"};
vector<string> opt2 = {"ZX","ZY"};
state *= 3;
for (auto x : opt0){
if (x==t) state += 0;
}
for (auto x : opt1){
if (x==t) state += 1;
}
for (auto x : opt2){
if (x==t) state += 2;
}
}
for (int x = 45; x>=0; x--){
if (state&(1LL<<x)){
Send(1);
}
else Send(0);
}
//printf("%lld\n",state);
}
}
#include "Bruno.h"
#include <vector>
#include <cassert>
#include <algorithm>
using namespace std;
void Bruno(int N, int L, std::vector<int> A) {
// assert(L==N+17);
int Xpos = 0;
int Zpos = 0;
for (int x = 0; x<17; x++){
Xpos = (Xpos<<1)+A[x];
}
if (Xpos==(1<<17)-1){
for (int x = 0; x<N; x++){
Remove(x);
}
return;
}
vector<int> rem;
for (int x = 0; x<Xpos; x++){
Remove(x);
}
int c = Xpos+1;
for (int x = 17; x<A.size(); x+=46){
long long state = 0;
for (int y = 0; y<46; y++){
state *= 2LL;
state += (long long)A[x+y];
}
//printf("%lld\n",state);
vector<int> things;
for (int x = 0; x<29; x++){
things.push_back(state%3);
state /= 3;
}
reverse(things.begin(),things.end());
for (int y = 0; y<29; y++){
if (things[y]==0){
rem.push_back(c+2*y);
rem.push_back(c+2*y+1);
}
else if (things[y]==1){
Remove(c+2*y);
while (!rem.empty()){
Remove(rem.back());
rem.pop_back();
}
Remove(c+y*2+1);
}
else if (things[y]==2){
while (!rem.empty()){
Remove(rem.back());
rem.pop_back();
}
Remove(c+2*y);
rem.push_back(c+y*2+1);
}
}
c+=58;
}
Remove(Xpos);
for (auto x : rem){
if (x<N)
Remove(x);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |