Submission #466731

#TimeUsernameProblemLanguageResultExecution timeMemory
466731mtxasRack (eJOI19_rack)C++14
40 / 100
1 ms312 KiB
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> #define fi first #define se second #define pll pair<ll, ll> #define mii map<int, int> #define vi vector<int> #define vll vector<ll> #define pb push_back #define all(a) a.begin(), a.end() #define sz(x) ((int)x.size()) #define turbo() cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false) #define _fre() freopen("input.txt", "r", stdin) #define _for(a, b, c) for(int (a) = (b); (a) < (c); (a)++) #define _foreq(a, b, c) for(int (a) = (b); (a) <= (c); (a)++) #define _forneq(a, b, c) for(int (a) = (b); (a) >= (c); (a)--) #define _forn(a, b, c) for(int (a) = (b); (a) > (c); (a)--) using namespace std; /********************************************************************************** STRUCTS **********************************************************************************/ /********************************************************************************** VARIABLES **********************************************************************************/ /********************************************************************************** FUNCTIONS **********************************************************************************/ /********************************************************************************** MAIN **********************************************************************************/ int main(){ //_fre(); //freopen("input.txt", "w", stdout); turbo(); ll n, k; cin>>n>>k; stack<char> stek; ll g = 1; _for(i, 0, n) g*= 2; _forneq(h, n, 1){ int mid = g/2; if(k > mid) k-= mid, stek.push('R'); else stek.push('L'); g/= 2; } int v = 1; while(!stek.empty()){ char c= stek.top(); stek.pop(); if(c == 'L') v = 2*v; else if(c=='R') v = 2*v+1; } g = 1; _for(i, 0, n) g*= 2; cout<<v-g+1; }

Compilation message (stderr)

rack.cpp: In function 'int main()':
rack.cpp:16:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   16 | #define _for(a, b, c) for(int (a) = (b); (a) < (c); (a)++)
      |                               ^
rack.cpp:42:15: note: in expansion of macro '_for'
   42 |     ll g = 1; _for(i, 0, n) g*= 2;
      |               ^~~~
rack.cpp:18:34: warning: unnecessary parentheses in declaration of 'h' [-Wparentheses]
   18 | #define _forneq(a, b, c) for(int (a) = (b); (a) >= (c); (a)--)
      |                                  ^
rack.cpp:43:5: note: in expansion of macro '_forneq'
   43 |     _forneq(h, n, 1){
      |     ^~~~~~~
rack.cpp:16:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   16 | #define _for(a, b, c) for(int (a) = (b); (a) < (c); (a)++)
      |                               ^
rack.cpp:55:12: note: in expansion of macro '_for'
   55 |     g = 1; _for(i, 0, n) g*= 2;
      |            ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...