답안 #435038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
435038 2021-06-22T21:14:25 Z NintsiChkhaidze Rack (eJOI19_rack) C++14
40 / 100
85 ms 11128 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define left (node<<1),l,((l+r)>>1)
#define right ((node<<1)|1),((l+r)>>1) + 1,r
#define s second
#define f first
using namespace std;
vector <int> v;
map <int,int> f;
int main (){
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    
    int a = (1<<(n - 1));
    v.pb(1);
    if (k == 1){
        cout<<1;
        return 0;
    }
    f[1] = 1;
    
    while(a){
        int id = 0;
        while(id < v.size() && v[id] + a <= (1<<n) && !f[v[id] + a]){
            f[v[id] + a] = 1;
            v.pb(v[id] + a);
            if (v.size() == k) {
                cout<<v[id] + a;
                return 0;
            }
            id++;
        }
        a/=2;
    }
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         while(id < v.size() && v[id] + a <= (1<<n) && !f[v[id] + a]){
      |               ~~~^~~~~~~~~~
rack.cpp:29:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |             if (v.size() == k) {
      |                 ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 440 KB Output is correct
8 Correct 14 ms 3144 KB Output is correct
9 Correct 55 ms 8520 KB Output is correct
10 Correct 85 ms 11128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 440 KB Output is correct
8 Correct 14 ms 3144 KB Output is correct
9 Correct 55 ms 8520 KB Output is correct
10 Correct 85 ms 11128 KB Output is correct
11 Incorrect 1 ms 332 KB Output isn't correct
12 Halted 0 ms 0 KB -