Submission #1052274

# Submission time Handle Problem Language Result Execution time Memory
1052274 2024-08-10T12:55:47 Z Nickpapadak Rack (eJOI19_rack) C++14
40 / 100
2 ms 2140 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned ll MAXN = 2e+6 + 10;
long long N,N2, K;
// ll seg[4*MAXN];
stack<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(ll indx){
//     if(seg[2*indx]) return findInbalance(2*indx);
//     if(seg[2*indx+1]) return findInbalance(2*indx+1);
//     return indx;
// }

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

        if(AddToQueue(i+NN2, NN2)) return 1;
        // 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){s
    return 0;
}

Compilation message

rack.cpp: In function 'long long int AddToQueue(long long int, long long int)':
rack.cpp:33:21: warning: comparison of integer expressions of different signedness: 'std::stack<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   33 |         if(q.size() == K){
      |            ~~~~~~~~~^~~~
rack.cpp: In function 'int main()':
rack.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |     scanf("%lld%lld", &N, &K);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 860 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 2 ms 2140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 860 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 2 ms 2140 KB Output is correct
11 Incorrect 0 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -