Submission #634275

# Submission time Handle Problem Language Result Execution time Memory
634275 2022-08-24T08:21:23 Z antimirage Rack (eJOI19_rack) C++14
40 / 100
16 ms 16212 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;

long long n, k, ans, mod = 1e9 + 7, two[N];

main(){
    cin >> n >> k;
    
    two[0] = 1;
    for (int i = 1; i < N; i++) {
        two[i] = two[i - 1] * 2 % mod;
    }
    
    long long pw = n;
    for (long long j = 0; j <= n; j++) {
        assert(j <= 60);
        if (k <= (1 << j)) {
            if (j > 0) 
                ans = (ans + two[pw]) % mod;
            else {
                cout << (ans + 1) % mod << endl;
                return 0;
            }
            k -= (1 << (j - 1));
            pw = n;
            j = -1;
        } else {
            pw--;
        }
    }
}

Compilation message

rack.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8036 KB Output is correct
2 Correct 10 ms 8020 KB Output is correct
3 Correct 8 ms 8020 KB Output is correct
4 Correct 8 ms 8020 KB Output is correct
5 Correct 8 ms 8020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8036 KB Output is correct
2 Correct 10 ms 8020 KB Output is correct
3 Correct 8 ms 8020 KB Output is correct
4 Correct 8 ms 8020 KB Output is correct
5 Correct 8 ms 8020 KB Output is correct
6 Correct 8 ms 8020 KB Output is correct
7 Correct 9 ms 8096 KB Output is correct
8 Correct 9 ms 8132 KB Output is correct
9 Correct 8 ms 8020 KB Output is correct
10 Correct 11 ms 8020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8036 KB Output is correct
2 Correct 10 ms 8020 KB Output is correct
3 Correct 8 ms 8020 KB Output is correct
4 Correct 8 ms 8020 KB Output is correct
5 Correct 8 ms 8020 KB Output is correct
6 Correct 8 ms 8020 KB Output is correct
7 Correct 9 ms 8096 KB Output is correct
8 Correct 9 ms 8132 KB Output is correct
9 Correct 8 ms 8020 KB Output is correct
10 Correct 11 ms 8020 KB Output is correct
11 Correct 9 ms 8020 KB Output is correct
12 Runtime error 16 ms 16212 KB Execution killed with signal 6
13 Halted 0 ms 0 KB -