답안 #700920

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
700920 2023-02-19T12:16:35 Z Doncho_Bonboncho Zalmoxis (BOI18_zalmoxis) C++14
5 / 100
145 ms 10432 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{
			
				nas.push_back( curr );
				/*
		//	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 135 ms 10328 KB Unexpected end of file - int32 expected
2 Incorrect 135 ms 10368 KB Unexpected end of file - int32 expected
3 Incorrect 134 ms 10260 KB Unexpected end of file - int32 expected
4 Incorrect 133 ms 10296 KB Unexpected end of file - int32 expected
5 Incorrect 132 ms 10424 KB Unexpected end of file - int32 expected
6 Incorrect 134 ms 10432 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 129 ms 10428 KB Unexpected end of file - int32 expected
2 Correct 134 ms 10260 KB Output is correct
3 Incorrect 143 ms 10304 KB Unexpected end of file - int32 expected
4 Incorrect 133 ms 10268 KB Unexpected end of file - int32 expected
5 Incorrect 136 ms 10360 KB Unexpected end of file - int32 expected
6 Incorrect 145 ms 10360 KB Unexpected end of file - int32 expected
7 Incorrect 136 ms 10296 KB Unexpected end of file - int32 expected
8 Incorrect 134 ms 10304 KB Unexpected end of file - int32 expected
9 Incorrect 115 ms 9144 KB Unexpected end of file - int32 expected
10 Incorrect 51 ms 4292 KB Unexpected end of file - int32 expected
11 Incorrect 81 ms 6396 KB Unexpected end of file - int32 expected
12 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
13 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
14 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected