답안 #1052175

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1052175 2024-08-10T12:15:36 Z Nickpapadak Rack (eJOI19_rack) C++14
40 / 100
6 ms 8832 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int MAXN = 2e+6 + 10;
long long N,N2, K;
int seg[4*MAXN];
queue<ll> q;
int Update(int low, int high, int i, int indx){
    if(low > i || high < i) return seg[indx];
    if(low == high && low == i) {
        seg[indx] = 1;
        return seg[indx];
    }
    int mid = (low+high)>>1;
    seg[indx] = Update(low, mid, i, 2*indx) - Update(mid+1, high, i, 2*indx+1);
    return seg[indx];
}

int findInbalance(int indx){
    if(seg[2*indx]) return findInbalance(2*indx);
    if(seg[2*indx+1]) return findInbalance(2*indx+1);
    return indx;
}

int AddToQueue(ll i, ll add){
    
    // int s = N2 - add; // 2
    ll NN2 = N2; // 3
    while(NN2 > add){
        // if(q.size() == K){
        //     printf("%lld", q.front());
        //     return 1;
        // }
        q.push(i+NN2);

        AddToQueue(i+NN2, NN2);
        // s = s>>1;
        NN2 = NN2 >>1;
    }
    return 0;
}

int main(){
    scanf("%lld%lld", &N, &K);
    N2 = 1 << (N-1);
    q.push(1);
    // printf("%lld\n", N2);
    AddToQueue(1, 0);
    for(int i = 1; i < K; ++i){
        q.pop();
    }printf("%lld ", q.front());
    return 0;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     scanf("%lld%lld", &N, &K);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 348 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 2 ms 2500 KB Output is correct
10 Correct 6 ms 8832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 348 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 2 ms 2500 KB Output is correct
10 Correct 6 ms 8832 KB Output is correct
11 Runtime error 1 ms 600 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -