Submission #131926

# Submission time Handle Problem Language Result Execution time Memory
131926 2019-07-18T04:31:29 Z maruii Zalmoxis (BOI18_zalmoxis) C++14
15 / 100
179 ms 14420 KB
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int A[1000006];

void f(int x, int m) {
	if (m < 1) return;
	if (m == 1) {
		cout << x << ' ';
		return;
	}
	f(x - 1, m / 2);
	f(x - 1, m - m / 2);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int N, K; cin >> N >> K;
	for (int i = 1; i <= N; ++i) cin >> A[i];
	vector<int> v;
	vector<pii> ans;
	for (int i = 1; i <= N; ++i) {
		while (v.size() && v.back() < A[i]) {
			ans.push_back(pii(v.back(), 1));
			v.push_back(v.back());
			while (v.size() > 1 && v.back() == v[v.size() - 2]) {
				v.pop_back();
				++v.back();
			}	
		}
		ans.push_back(pii(A[i], 0));
		v.push_back(A[i]);
		while (v.size() > 1 && v.back() == v[v.size() - 2]) {
			v.pop_back();
			++v.back();
		}
	}
	for (int i = v.back(); i < 30; ++i) ans.push_back(pii(i, 1));
	int j = N + K - ans.size();
	for (auto i : ans) {
		if (i.second && j) {
			if (j >= (1 << i.first) - 1) {
				j -= (1 << i.first) - 1;
				for (int k = (1 << i.first); k; --k) cout << 0 << ' ';
			}
			else f(i.first, j + 1), j = 0;
		}
		else cout << i.first << ' ';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 176 ms 14264 KB Expected EOF
2 Incorrect 171 ms 14296 KB Expected EOF
3 Incorrect 170 ms 14296 KB Expected EOF
4 Incorrect 179 ms 14420 KB Expected EOF
5 Incorrect 170 ms 14292 KB Expected EOF
6 Incorrect 170 ms 14364 KB Expected EOF
# Verdict Execution time Memory Grader output
1 Incorrect 177 ms 14400 KB not a zalsequence
2 Correct 171 ms 14300 KB Output is correct
3 Correct 171 ms 14292 KB Output is correct
4 Incorrect 170 ms 14288 KB not a zalsequence
5 Incorrect 170 ms 14264 KB not a zalsequence
6 Incorrect 170 ms 14292 KB not a zalsequence
7 Incorrect 171 ms 14292 KB not a zalsequence
8 Incorrect 173 ms 14420 KB not a zalsequence
9 Incorrect 161 ms 13012 KB not a zalsequence
10 Incorrect 111 ms 7040 KB not a zalsequence
11 Incorrect 135 ms 10592 KB not a zalsequence
12 Incorrect 75 ms 2296 KB not a zalsequence
13 Incorrect 74 ms 2296 KB not a zalsequence
14 Correct 77 ms 2424 KB Output is correct