답안 #440435

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
440435 2021-07-02T09:12:33 Z stoyan_malinin Rack (eJOI19_rack) C++14
40 / 100
1000 ms 204 KB
#include <iostream>

using namespace std;

long long n, k;

long long getNum(long long pos, int p2, int seqPos)
{
    while(seqPos+(1LL<<(n-1-p2))<=pos)
    {
        seqPos += (1LL<<(n-1-p2));
        p2++;
    }
    if(pos==seqPos) return (1LL<<(p2 - (k%2==0)));

    //cout << pos << " " << p2 << " " << seqPos << '\n';

    long long nextSeqPos = seqPos+(1LL<<(n-1-p2));
    long long diff = pos - seqPos;

    return getNum(nextSeqPos+diff, p2, seqPos) - (1<<p2);
}

int main()
{
    cin >> n >> k;
    if(k==1)
    {
        cout << "1" << '\n';
        return 0;
    }

    //for(int k = 2;k<=(1<<n);k++)
        cout << getNum(k, 0, 1) << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Execution timed out 1081 ms 204 KB Time limit exceeded
12 Halted 0 ms 0 KB -