Submission #386314

#TimeUsernameProblemLanguageResultExecution timeMemory
386314model_codeAncient Machine (JOI21_ancient_machine)C++17
100 / 100
79 ms8524 KiB
#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)

Anna.cpp: In function 'void Anna(int, std::vector<char>)':
Anna.cpp:42:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for(int i=0;i<x.size();i+=A){
      |               ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...