답안 #700917

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
700917 2023-02-19T12:09:48 Z Doncho_Bonboncho Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
171 ms 12476 KB
#include <bits/stdc++.h>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int MAX_N = 1e6 + 42;
const int INF = 1e9;
const int mod = 1e9 + 7;

int a[MAX_N];

ll paw[32];

int main () {

	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);

	int n, k;
	std::cin>>n>>k;

	for( int i=0 ; i<n ; i++ ) std::cin>>a[i];
	a[n] = INF;

	ll step = 1;
	for( int i=0 ; i<=30 ; i++ ){
		paw[i] = step;
		step <<= 1;
	}

	std::stack<int> st;
	st.push(30);

	std::vector<int> nas;

	int ind = 0;
	while( ind != n ){
		int curr = st.top();
	//	std::cerr<<curr<<"\n";
		st.pop();
		if( curr == a[ind] ){
			nas.push_back(curr);
			ind++;
		}else{
			if( curr > a[ind] ){
				st.push( curr-1 );
				st.push( curr-1 );
			}else{
		//	std::cerr<<curr<<" "<<paw[curr]<<"\n";
				if( k > paw[curr] ){
					k -= paw[curr];
					for( int i=0 ; i<paw[curr] ; i++ ) nas.push_back(1);
				}else{
					int st = 0;
					while( k ){
						if( k & 1 ){
							for( int i=0 ; i<paw[st] ; i++ ) nas.push_back(curr - st);
						}
						st++;
						k >>= 1;
					}
				}
			}
		}
	}

	while( !st.empty()  ){
		int curr = st.top();
		st.pop();
		if( k > paw[curr] ){
					k -= paw[curr];
					for( int i=0 ; i<paw[curr] ; i++ ) nas.push_back(1);
				}else{
					int st = 0;
					while( k ){
						if( k & 1 ){
							for( int i=0 ; i<paw[st] ; i++ ) nas.push_back(curr - st-1);
						}
						st++;
						k >>= 1;
					}
				}


	//	std::cerr<<curr<<"\n";
	}

	for( auto j : nas ) std::cout<<j<<" ";
	std::cout<<"\n";

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 134 ms 12400 KB not a zalsequence
2 Incorrect 135 ms 12384 KB not a zalsequence
3 Incorrect 130 ms 12448 KB not a zalsequence
4 Incorrect 130 ms 12344 KB not a zalsequence
5 Incorrect 136 ms 12432 KB not a zalsequence
6 Incorrect 144 ms 12376 KB not a zalsequence
# 결과 실행 시간 메모리 Grader output
1 Incorrect 143 ms 12344 KB not a zalsequence
2 Incorrect 163 ms 12396 KB not a zalsequence
3 Incorrect 138 ms 12360 KB not a zalsequence
4 Incorrect 131 ms 12420 KB not a zalsequence
5 Incorrect 140 ms 12476 KB not a zalsequence
6 Incorrect 132 ms 12368 KB not a zalsequence
7 Incorrect 131 ms 12412 KB not a zalsequence
8 Incorrect 138 ms 12472 KB not a zalsequence
9 Incorrect 128 ms 11192 KB not a zalsequence
10 Incorrect 150 ms 8176 KB not a zalsequence
11 Incorrect 171 ms 9412 KB not a zalsequence
12 Incorrect 77 ms 6356 KB not a zalsequence
13 Incorrect 73 ms 6316 KB not a zalsequence
14 Incorrect 74 ms 6328 KB not a zalsequence