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>
using namespace std;
const int M = 2000;
namespace {
vector<int> lookup = {
0,
1,
3,
7,
15,
31,
};
tuple<int,int,int,int> generate(long long x){
long long curr = 0;
for(int len=64;len<=M;len++){
if(curr+36*(2*(len-2)-123)-1<x){
curr+=36*(2*(len-2)-123);
continue;
}
for(int turnedon=124;turnedon<=2*len-4;turnedon++){
for(int starting=0;starting<6;starting++){
for(int ending=0;ending<6;ending++){
if(curr++==x)return {len,turnedon,lookup[starting],lookup[ending]};
}
}
}
}
assert(false);
}
}
int Declare() {return M;}
pair<vector<int>, vector<int>> Anna(long long A) {
auto [len,ones,starting,ending] = generate(A);
vector<int> a(len,0),b(len,0);
for(int i=0;i<starting;i++){
a[i]=b[i]=1;
ones-=2;
}
for(int i=0;i<ending;i++){
a[len-i-1]=b[len-i-1]=1;
ones-=2;
}
for(int i=starting+1;i<len;i++){
if(ones){a[i]=1;ones--;}
if(ones){b[i]=1;ones--;}
}
return {a,b};
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
const int M = 2000;
namespace {
long long generate(int tarlen,int taron,int tarstarting,int tarending){
long long curr = 0;
for(int len=64;len<=M;len++){
if(len!=tarlen){
curr+=36*(2*(len-2)-123);
continue;
}
for(int turnedon=124;turnedon<=2*len-4;turnedon++){
if(turnedon!=taron){curr+=36;continue;}
for(int starting=0;starting<6;starting++){
if(starting!=tarstarting){curr+=6;continue;}
for(int ending=0;ending<6;ending++){
if(ending==tarending)return curr;
curr++;
}
}
}
}
assert(false);
}
}
long long Bruno(vector<int> u) {
int len = u.size()/2;
int ones = 0;
for(int&i:u)ones+=i;
int starting = 0;
for(int&i:u){
if(i) starting++;
else break;
}
reverse(u.begin(),u.end());
int ending = 0;
for(int&i:u){
if(i) ending++;
else break;
}
if(0<=starting and starting<=0)starting=0;
else if(1<=starting and starting<=2)starting=1;
else if(3<=starting and starting<=6)starting=2;
else if(7<=starting and starting<=14)starting=3;
else if(15<=starting and starting<=30)starting=4;
else if(31<=starting and starting<=62)starting=5;
if(0<=ending and ending<=0)ending=0;
else if(1<=ending and ending<=2)ending=1;
else if(3<=ending and ending<=6)ending=2;
else if(7<=ending and ending<=14)ending=3;
else if(15<=ending and ending<=30)ending=4;
else if(31<=ending and ending<=62)ending=5;
return generate(len,ones,starting,ending);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |