Submission #397705

#TimeUsernameProblemLanguageResultExecution timeMemory
397705AmineWeslatiAncient Machine (JOI21_ancient_machine)C++17
0 / 100
69 ms7976 KiB
#include "Anna.h" #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef vector<int>vi; #define sz(v) (int)v.size() #define pb push_back #define all(x) begin(x),end(x) typedef string str; #define FOR(i,a,b) for(int i=a; i<b; i++) #define ROF(i,a,b) for(int i=b-1; i>=a; i--) //-------------------------------------------------------// const int n=63,m=44; ll f[n]; void compute(){ f[0]=1; f[1]=2; FOR(i,2,n) f[i]=f[i-1]+f[i-2]; } ll encode(vi vec){ reverse(all(vec)); ll ans=0; FOR(i,0,n) if(vec[i]) ans+=f[i]; return ans; } void Anna(int N, vector<char>S) { vi a(N,0); int fir=-1; FOR(i,0,N){ if(S[i]=='X' && fir==-1){ a[i]=1; fir=i; } else if(S[i]=='Z' && fir!=-1 && i!=fir+1){ a[i]=1; } } while(sz(a)%n) a.pb(0); compute(); for(int i=0; i<sz(a); i+=n){ vi cur; FOR(j,i,i+n) cur.pb(a[j]); ll x=encode(cur); ROF(j,0,m){ Send((x>>j)&1); } } }
#include "Bruno.h" #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef vector<int>vi; #define sz(v) (int)v.size() #define pb push_back #define FOR(i,a,b) for(int i=a; i<b; i++) #define ROF(i,a,b) for(int i=b-1; i>=a; i--) //-------------------------------------------------------------// const int n=63,m=44; ll ff[n]; vi decode(ll val){ vi vec; ROF(i,0,n){ if(ff[i]<=val){ vec.pb(1); val-=ff[i]; } else vec.pb(0); } return vec; } void Bruno(int N, int L, vi a){ ff[0]=1; ff[1]=2; FOR(i,2,n) ff[i]=ff[i-1]+ff[i-2]; vi vec; for(int i=0; i<sz(a); i+=m){ ll cur=0; FOR(j,i,i+m){ cur*=2; cur+=a[j]; } vi v=decode(cur); for(int x: v) vec.pb(x); } int i=0; while(vec[i]==0){ Remove(i); i++; } int l=i,f=i; i++; for(;i<N; i++){ if(vec[i]){ int r=i; ROF(j,l+1,i){ Remove(j); } Remove(i); l=i; } else if(i==N-1){ FOR(j,l+1,i+1) Remove(j); } } Remove(f); }

Compilation message (stderr)

Bruno.cpp: In function 'void Bruno(int, int, vi)':
Bruno.cpp:55:8: warning: unused variable 'r' [-Wunused-variable]
   55 |    int r=i;
      |        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...