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 {
tuple<int,int,int> generate(long long x){
long long curr = 0;
for(int len=4;len<=M;len++){
if(curr+3*(2*(len-1)-5)-1<x){
curr+=3*(2*(len-1)-5);
continue;
}
for(int turnedon=6;turnedon<=2*(len-1);turnedon++){
if(curr++==x)return {len,turnedon,0};
if(curr++==x)return {len,turnedon,1};
if(curr++==x)return {len,turnedon,3};
}
}
assert(false);
}
}
int Declare() {return M;}
pair<vector<int>, vector<int>> Anna(long long A) {
auto [len,ones,starting] = 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=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 starting){
long long curr = 0;
for(int len=4;len<=M;len++){
if(len!=tarlen){
curr+=3*(2*(len-1)-5);
continue;
}
for(int turnedon=6;turnedon<=2*(len-1);turnedon++){
if(turnedon!=taron){curr+=3;continue;}
if(starting==0)return curr;
curr++;
if(starting==1)return curr;
curr++;
if(starting==3)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;
}
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=3;
return generate(len,ones,starting);
}
# | 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... |