# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
272827 | EJOI2019Andrew | Rack (eJOI19_rack) | C++14 | 0 ms | 256 KiB |
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 MOD 1000000007
string s;
map<long long int,int>freq;
void rack(long long int k)
{
if(freq[k]>1&&k==1)
return;
if(k%2)
s+='L';
else
s+='R';
int fr(k%2);
k/=2;
k+=fr;
++freq[k];
rack(k);
}
long long int sol(long long int n)
{
long long int l(0),r(pow(2,n));
for(int i=0; i<s.length(); ++i)
{
long long int mid=(l+r)/2;
if(s[i]=='L')
r=mid-1;
else
l=mid+1;
}
return l%MOD;
}
int main()
{
//EWEX
//SXSN
//WSEX
long long int n,k;
cin>>n>>k;
rack(k);
cout<<sol(n);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |