Submission #867475

# Submission time Handle Problem Language Result Execution time Memory
867475 2023-10-28T13:03:03 Z pizzamoeger Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
112 ms 13036 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main () {
	cin.tie(0);
	ios_base::sync_with_stdio(0);

	int n, k; cin >> n >> k;
	vector<int> S (n);
	for (int i = 0; i < n; i++) cin >> S[i];

	stack<int> nums;
	vector<pair<int,int>> inserts;
	int i = 0;
	while (i < n) {
		int cur = S[i];
		while (!nums.empty()) {
			int top = nums.top();
			//cerr << cur << " " << top << " " << i << "\n";
			if (cur == top) {
				cur++;
				nums.pop();
			} else if (cur > top) {
				inserts.push_back({i, top});
				cur = top+1;
				nums.pop();
				i--;
			} else {
				nums.push(cur);
				break;
			}
		}
		if (nums.empty()) 	nums.push(cur);
		i++;
	}

	if (!nums.empty() && nums.top() != 30) inserts.push_back({n, nums.top()});

	int left = k-inserts.size();

	vector<int> new_s;
	int j = 0;
	for (int i = 0; i < n; i++) {
		while (j < inserts.size() && i == inserts[j].first) {
			int cnt = inserts[j].second;
			while (left > 2 && cnt > 0) {
				cout << cnt << " ";
				cnt--;
				left--;
			}
			cout << cnt << " " << cnt << " ";
			j++;
		}
		cout << S[i] << " ";
	}
	while (j < inserts.size() && n == inserts[j].first) {
		int cnt = inserts[j].second;
		while (left > 2 && cnt > 0) {
			cout << cnt << " ";
			cnt--;
			left--;
		}
		j++;
	}
	cout << "\n";
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:46:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   while (j < inserts.size() && i == inserts[j].first) {
      |          ~~^~~~~~~~~~~~~~~~
zalmoxis.cpp:58:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |  while (j < inserts.size() && n == inserts[j].first) {
      |         ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 94 ms 10340 KB Unexpected end of file - int32 expected
2 Incorrect 94 ms 10332 KB Unexpected end of file - int32 expected
3 Incorrect 100 ms 10352 KB Unexpected end of file - int32 expected
4 Incorrect 94 ms 10324 KB Unexpected end of file - int32 expected
5 Incorrect 112 ms 10320 KB Unexpected end of file - int32 expected
6 Incorrect 94 ms 10324 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 94 ms 10320 KB Unexpected end of file - int32 expected
2 Incorrect 99 ms 10320 KB Expected EOF
3 Incorrect 94 ms 10320 KB Expected EOF
4 Incorrect 94 ms 10320 KB Expected EOF
5 Incorrect 96 ms 10204 KB Expected EOF
6 Incorrect 94 ms 10256 KB Unexpected end of file - int32 expected
7 Incorrect 94 ms 10320 KB Unexpected end of file - int32 expected
8 Incorrect 96 ms 10316 KB Unexpected end of file - int32 expected
9 Incorrect 102 ms 13036 KB Expected EOF
10 Incorrect 73 ms 8524 KB Expected EOF
11 Incorrect 99 ms 10176 KB Expected EOF
12 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
13 Incorrect 0 ms 344 KB Unexpected end of file - int32 expected
14 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected