Submission #278075

# Submission time Handle Problem Language Result Execution time Memory
278075 2020-08-21T09:47:37 Z petar_vitorac Rack (eJOI19_rack) C++11
0 / 100
1 ms 256 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long

class ConstSizeVector {
	public:
		ConstSizeVector(int size) : v(size), totalsize(size) {}
		
		void pb(int n) {
			v[currsize] = n;
			currsize++;
		}
		
		int get(int i) {
			return v[i];
		}
		
		int getSize() {
			return currsize;
		}
		
	private:
		vector<int> v;
		int totalsize;
		int currsize = 0;
};

int mypow(int base, int exp) {
	int result = 1;
	
	for(int i = 1; i <= exp; i++) {
		result*=base;
	}
	
	return result;
}

signed main() {
	int n, k; cin >> n >> k;
	
	int totalOps = mypow(2, n);
	int tosubtractatend = 0;
	
	ConstSizeVector reversedOps (totalOps);
	
	if(k <= totalOps/2) {
		k+=totalOps/2;
		tosubtractatend = 1;		
	}
	

	
	reversedOps.pb(totalOps);
	while(totalOps - reversedOps.getSize() >= k) {
		int sizebefore = reversedOps.getSize();
		int tosubtract = totalOps/2/sizebefore;
		for(int i = 0; i < sizebefore; i++) {
			reversedOps.pb(reversedOps.get(i)-tosubtract);
		}
	}
	
	
	cout << reversedOps.get(totalOps - (k-totalOps/2)) - tosubtractatend << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -