# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
999786 |
2024-06-16T06:54:07 Z |
vjudge1 |
Rack (eJOI19_rack) |
C++17 |
|
1 ms |
348 KB |
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define f first
#define s second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define p_b pop_back
using namespace std;
const ll mod = 1e9+7;
ll binpow(ll a, ll b)
{
ll res = 1;
while(b)
{
if(b & 1)
res = res * a;
a *= a;
b >>= 1;
}
return res;
}
ll f(ll l, ll r, ll g)
{
for(ll j = l+1; j <= r; j++)
g = 2 * g - 1;
return g;
}
void solve()
{
ll n, k, tk;
cin >> n >> k;
tk = k;
vl vect;
while(k > 2 && binpow(2, log2(k)) != k)
{
vect.pb(k);
ll f = log2(k);
k -= binpow(2, f);
}
/*for(auto u : vect)
cout << u << ' ';
cout << "\n";*/
ll lstlvl = log2(k), lstval = k;
while(vect.size())
{
ll m = log2(vect.back() - k) + 1;
ll b = f(lstlvl, m, lstval);
lstlvl = m;
lstval = b + 1;
k = vect.back();
vect.pop_back();
}
lstval = f(lstlvl, n, lstval);
cout << lstval << "\n";
}
int main()
{
//ios_base::sync_with_stdio(0);
//cin.tie(0);
//cout.tie(0);
ll tests = 1;
//cin >> tests;
while(tests--)
{
solve();
}
}
Compilation message
rack.cpp: In function 'void solve()':
rack.cpp:36:14: warning: variable 'tk' set but not used [-Wunused-but-set-variable]
36 | ll n, k, tk;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |