Submission #435306

#TimeUsernameProblemLanguageResultExecution timeMemory
435306NintsiChkhaidzeRack (eJOI19_rack)C++14
40 / 100
100 ms15344 KiB
#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 #define int ll using namespace std; vector <int> v; map <int,int> f; 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 (stderr)

rack.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main (){
      | ^~~~
rack.cpp: In function 'int main()':
rack.cpp:27:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         while(id < v.size() && v[id] + a <= (1<<n) && !f[v[id] + a]){
      |               ~~~^~~~~~~~~~
rack.cpp:30:26: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   30 |             if (v.size() == k) {
      |                 ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...