Submission #1099130

#TimeUsernameProblemLanguageResultExecution timeMemory
1099130vjudge1Rack (eJOI19_rack)C++17
40 / 100
0 ms348 KiB
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int height, node;
    cin >> height >> node;
    int rows = 1 << height;

    std::vector<int> path(height);
    for (int j = 0; j < height; ++j) {
        path[j] = ((node - 1) >> j) & 1;
    }
    

    long long int leaf = 1;
    long long int set = pow(2, height);
    for (int i : path)
    {
        set = set/2;
        if (i == 1) leaf += set;
    }

    cout << leaf << endl;
    return 0;
}

Compilation message (stderr)

rack.cpp: In function 'int main()':
rack.cpp:14:9: warning: unused variable 'rows' [-Wunused-variable]
   14 |     int rows = 1 << height;
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...