답안 #65186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
65186 2018-08-07T00:57:59 Z spencercompton Zalmoxis (BOI18_zalmoxis) C++14
100 / 100
544 ms 83568 KB
#include <bits/stdc++.h>
using namespace std;
int n, k;
void f(int now){
	if(now==0 || k==0){
		cout << " " << now;
		return;
	}
	k--;
	f(now-1);
	f(now-1);
}
int main(){
	cin >> n >> k;
	vector<pair<int, int> > li;
	for(int i = 0; i<n; i++){
		int x;
		cin >> x;
		li.push_back(make_pair(i,x));
	}
	vector<pair<int, int> > cur;
	cur = li;
	vector<int> add[n];
	int use = 0;
	for(int i = 0; i<30; i++){
		vector<pair<int, int> > nxt;
		nxt.push_back(cur[0]);
		for(int j = 1; j<cur.size(); j++){
			int bef = nxt.back().second;
			int now = cur[j].second;
			if(bef==i){
				if(now==i){
					nxt.back().second++;
					nxt.back().first = cur[j].first;
				}
				else{
					nxt.back().second++;
					add[nxt.back().first].push_back(i);
					k--;
					use++;
					nxt.push_back(cur[j]);
				}
			}
			else{
				nxt.push_back(cur[j]);
			}
		}
		if(nxt.back().second==i){
			nxt.back().second++;
			add[nxt.back().first].push_back(i);
			k--;
			use++;
		}
		cur = nxt;
	}
	for(int i = 0; i<n; i++){
		if(i>0){
			cout << " ";
		}
		cout << li[i].second;
		for(int j = 0; j<add[i].size(); j++){
			f(add[i][j]);
		}
	}
	cout << endl;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:28:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 1; j<cur.size(); j++){
                  ~^~~~~~~~~~~
zalmoxis.cpp:61:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j<add[i].size(); j++){
                  ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 445 ms 56272 KB Output is correct
2 Correct 500 ms 58620 KB Output is correct
3 Correct 521 ms 60624 KB Output is correct
4 Correct 483 ms 62876 KB Output is correct
5 Correct 544 ms 65008 KB Output is correct
6 Correct 500 ms 66496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 487 ms 68796 KB Output is correct
2 Correct 505 ms 70704 KB Output is correct
3 Correct 440 ms 73060 KB Output is correct
4 Correct 492 ms 75100 KB Output is correct
5 Correct 493 ms 77112 KB Output is correct
6 Correct 538 ms 78980 KB Output is correct
7 Correct 507 ms 81264 KB Output is correct
8 Correct 518 ms 83568 KB Output is correct
9 Correct 440 ms 83568 KB Output is correct
10 Correct 218 ms 83568 KB Output is correct
11 Correct 301 ms 83568 KB Output is correct
12 Correct 99 ms 83568 KB Output is correct
13 Correct 110 ms 83568 KB Output is correct
14 Correct 111 ms 83568 KB Output is correct