Submission #928746

#TimeUsernameProblemLanguageResultExecution timeMemory
928746bachhoangxuanBroken Device 2 (JOI22_device2)C++17
100 / 100
53 ms3416 KiB
#include "Anna.h" #include <bits/stdc++.h> using namespace std; #define ll long long namespace AA{ const int L=140; ll dp[L+5]; void init(){ dp[1]=dp[2]=1;dp[3]=2; for(int i=4;i<=L;i++) dp[i]=dp[i-2]+dp[i-3]+1; } pair<vector<int>,vector<int>> solve(long long A){ init(); int l=1,x=A&1;A>>=1; while(A>=dp[l]) A-=dp[l++]; vector<int> a(l,0),b(l,0); for(int i=0;i<l;i++) a[i]=(x+i)&1; b[0]=x; for(int i=1;i<l;i++){ if(A==0) b[i]=b[i-1]^1; else if(A<=dp[l-i-1]) A--,b[i]=b[i+1]=b[i-1],i++; else A-=(dp[l-i-1]+1),b[i]=b[i+1]=b[i+2]=b[i-1]^1,i+=2; } return {a,b}; } } int Declare(){ return 140; } std::pair<std::vector<int>, std::vector<int> > Anna(long long A) { return AA::solve(A); }
#include "Bruno.h" #include <bits/stdc++.h> using namespace std; #define ll long long namespace BB{ const int L=140; ll dp[L+5]; void init(){ dp[1]=dp[2]=1;dp[3]=2; for(int i=4;i<=L;i++) dp[i]=dp[i-2]+dp[i-3]+1; } ll solve(vector<int> x){ init(); ll A=x[0]; int l=(int)x.size()/2; for(int i=2*l-1;i>=0;i--) x[i]^=x[0]; for(int i=1;i<l;i++) A+=2*dp[i]; int c=0,d=0; for(int i=1,j=1;j<2*l;j++){ d+=(x[j]?-1:1); if(d>=2){ if(c==0) A+=2,i+=2; else A+=(dp[l-i-1]+1)*2,i+=3; c=d=0; } else if(d<=-2){ if(c==1) A+=2,i+=2; else A+=(dp[l-i-1]+1)*2,i+=3; c=1;d=0; } } return A; } } long long Bruno(std::vector<int> u) { return BB::solve(u); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...