#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define left (node<<1),l,((l+r)>>1)
#define right ((node<<1)|1),((l+r)>>1) + 1,r
#define s second
#define f first
#define int ll
using namespace std;
vector <int> v;
map <int,int> f;
main (){
ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
int n,k;
cin>>n>>k;
int a = (1<<(n - 1));
v.pb(1);
if (k == 1){
cout<<1;
return 0;
}
f[1] = 1;
while(a){
int id = 0;
while(id < v.size() && v[id] + a <= (1<<n) && !f[v[id] + a]){
f[v[id] + a] = 1;
v.pb(v[id] + a);
if (v.size() == k) {
cout<<v[id] + a;
return 0;
}
id++;
}
a/=2;
}
}
Compilation message
rack.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
12 | main (){
| ^~~~
rack.cpp: In function 'int main()':
rack.cpp:27:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | while(id < v.size() && v[id] + a <= (1<<n) && !f[v[id] + a]){
| ~~~^~~~~~~~~~
rack.cpp:30:26: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
30 | if (v.size() == k) {
| ~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
460 KB |
Output is correct |
8 |
Correct |
16 ms |
4292 KB |
Output is correct |
9 |
Correct |
83 ms |
11736 KB |
Output is correct |
10 |
Correct |
100 ms |
15344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
460 KB |
Output is correct |
8 |
Correct |
16 ms |
4292 KB |
Output is correct |
9 |
Correct |
83 ms |
11736 KB |
Output is correct |
10 |
Correct |
100 ms |
15344 KB |
Output is correct |
11 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |