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 <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define all(x) begin(x),end(x)
std::vector<std::vector<int>> devise_strategy(int N)
{
vector<vector<int>> s;
for(int i=0;i<=27;i++)
{
s.push_back({});
if(i==0) // start by checking the bit in a
{
s[i].push_back(0);
int check=13;
// number bit from 13 to 1
check--;
for(int result=1;result<=N;result++)
{
bool p=(result&(1<<check));
s[i].push_back(((check+1)*2)+p);
// even * 2 == multiple of four
// cout<<"For "<<i<<' '<<result<<' '<<(check*2)+p<<endl;;
}
continue;
}
if((i&2)==0) // now check bit in b
{
s[i].push_back(1);
int check=i/2;
bool oth=(i%2);
check--;
for(int result=1;result<=N;result++)
{
bool p=(result&(1<<check));
if(oth>p)
{
s[i].push_back(-2);
}
else if(oth<p)
{
s[i].push_back(-1);
}
else
{
if(check==0)
{
s[i].push_back(-1);
}
else
{
p=(result&(1<<(check-1)));
// cout<<"For "<<i<<' '<<result<<' '<<check-1<<' '<<p<<endl;
s[i].push_back(((check)*2)+p);
}
}
}
}
else// now check bit in a
{
s[i].push_back(0);
int check=i/2;
bool oth=(i%2);
check--;
for(int result=1;result<=N;result++)
{
bool p=(result&(1<<check));
if(oth>p)
{
// if(i==23)
// {
// cout<<"Now "<<result<<' '<<p<<' '<<oth<<' '<<check<<endl;
// }
s[i].push_back(-1);
}
else if(oth<p)
{
s[i].push_back(-2);
}
else
{
if(check==0)
{
s[i].push_back(-1);
}
else
{
p=(result&(1<<(check-1)));
// cout<<"For "<<i<<' '<<result<<' '<<check-1<<' '<<p<<endl;
s[i].push_back(((check)*2)+p);
}
}
}
}
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |