# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
386314 | model_code | Ancient Machine (JOI21_ancient_machine) | C++17 | 79 ms | 8524 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>
namespace{
int A=63,B=44;
long long fib[100];
void init(){
fib[0]=1;
fib[1]=2;
for(int i=2;i<=A;i++){
fib[i]=fib[i-1]+fib[i-2];
}
}
long long encode(std::vector<int>y){
reverse(y.begin(),y.end());
long long res=0;
for(int i=0;i<A;i++){
if(y[i]==1)res+=fib[i];
}
return res;
}
}
void Anna(int N,std::vector<char>S){
std::vector<int>x;
int p=0;
while(p<N&&S[p]!='X'){
x.push_back(0);
p++;
}
if(p<N){
x.push_back(1);
x.push_back(0);
p++;
}
for(;p<N;p++){
if(S[p]=='Z'&&(p==N-1||S[p+1]!='Z'))x.push_back(1);
else x.push_back(0);
}
while(x.size()%A!=0)x.push_back(0);
init();
for(int i=0;i<x.size();i+=A){
std::vector<int>y(A);
for(int j=0;j<A;j++){
y[j]=x[i+j];
}
long long s=encode(y);
for(long long j=0;j<B;j++)Send(s>>j&1);
}
}
#include "Bruno.h"
#include <bits/stdc++.h>
namespace{
std::vector<int>X;
int A=63,B=44;
long long fib[100];
void init(){
fib[0]=1;
fib[1]=2;
for(int i=2;i<=A;i++){
fib[i]=fib[i-1]+fib[i-2];
}
}
void decode(long long s){
for(int i=A-1;i>=0;i--){
if(fib[i]<=s){
s-=fib[i];
X.push_back(1);
}else X.push_back(0);
}
}
}
void Bruno(int N,int L,std::vector<int>x){
init();
for(int i=0;i<L;i+=B){
long long s=0;
for(long long j=0;j<B;j++)s+=(long long)x[i+j]<<j;
decode(s);
}
int p=0,l=0;
while(p<N&&!X[l]){
Remove(p);
p++;
l++;
}
int la=p,lx=p;
p++;
l+=2;
for(;p<N;p++,l++){
if(X[l]){
for(int i=p-1;i>la;i--)Remove(i);
Remove(p);
la=p;
}
}
for(int i=N-1;i>la;i--)Remove(i);
if(lx<N)Remove(lx);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |