답안 #430972

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
430972 2021-06-17T08:35:37 Z faresbasbs Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
247 ms 27688 KB
#include <bits/stdc++.h>
using namespace std;
vector<int> v[1000001];
int n,k,arr[1000001];

void solve(int l , int r , int val , int freq){
	if(val < 23){
		exit(0);
	}
	if(r == l-1){
		for(int i = 0 ; i < freq ; i += 1){
			v[r].push_back(val);
		}
		return ;
	}
	int pos = -1;
	for(int i = l ; i <= r ; i += 1){
		if(arr[i] == val){
			pos = i;
			break;
		}
	}
	if(pos == -1){
		solve(l,r,val-1,2*freq);
		return ;
	}
	int farr[31];
	memset(farr,0,sizeof farr);
	for(int i = l ; i < pos ; i += 1){
		farr[arr[i]] += 1;
	}
	int tag = 0;
	for(int i = 0 ; i < val ; i += 1){
		farr[i+1] += farr[i]/2;
		if(farr[i]%2 == 1){
			tag = 1;
		}
	}
	freq -= 1;
	solve(l,pos-1,val,farr[val]+tag),solve(pos+1,r,val,freq-farr[val]-tag);
}

int main(){
	cin >> n >> k;
	for(int i = 1 ; i <= n ; i += 1){
		cin >> arr[i];
	}
	solve(1,n,30,1);
	vector<int> varr;
	for(int i = 0 ; i <= n ; i += 1){
		for(auto j : v[i]){
			varr.push_back(j);
		}
		if(i){
			varr.push_back(arr[i]);
		}
	}
	for(auto i : varr){
		cout << i << " ";
	}cout << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 217 ms 27616 KB Unexpected end of file - int32 expected
2 Incorrect 204 ms 27600 KB Unexpected end of file - int32 expected
3 Incorrect 202 ms 27588 KB Unexpected end of file - int32 expected
4 Incorrect 202 ms 27588 KB Unexpected end of file - int32 expected
5 Incorrect 204 ms 27624 KB Unexpected end of file - int32 expected
6 Incorrect 216 ms 27588 KB Unexpected end of file - int32 expected
# 결과 실행 시간 메모리 Grader output
1 Incorrect 208 ms 27576 KB Unexpected end of file - int32 expected
2 Incorrect 201 ms 27552 KB Unexpected end of file - int32 expected
3 Incorrect 202 ms 27644 KB Unexpected end of file - int32 expected
4 Incorrect 215 ms 27688 KB Unexpected end of file - int32 expected
5 Incorrect 237 ms 27588 KB Unexpected end of file - int32 expected
6 Incorrect 206 ms 27568 KB Unexpected end of file - int32 expected
7 Incorrect 247 ms 27576 KB Unexpected end of file - int32 expected
8 Incorrect 210 ms 27612 KB Unexpected end of file - int32 expected
9 Incorrect 168 ms 26812 KB Unexpected end of file - int32 expected
10 Incorrect 72 ms 24900 KB Unexpected end of file - int32 expected
11 Incorrect 107 ms 25596 KB Unexpected end of file - int32 expected
12 Incorrect 14 ms 23736 KB Unexpected end of file - int32 expected
13 Incorrect 14 ms 23756 KB Unexpected end of file - int32 expected
14 Incorrect 14 ms 23672 KB Unexpected end of file - int32 expected