# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
466731 | 2021-08-20T14:37:40 Z | mtxas | Rack (eJOI19_rack) | C++14 | 1 ms | 312 KB |
#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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 312 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 312 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 312 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Incorrect | 1 ms | 204 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |