답안 #278194

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
278194 2020-08-21T11:14:31 Z test2 Zalmoxis (BOI18_zalmoxis) C++14
30 / 100
187 ms 16616 KB
#include<bits/stdc++.h>

#define I inline void 

using namespace std ; 

using ll = long long ; 
using ld = long double ; 

const int N = 2e6 + 7 ; 

// How interesting!

int n , k ; 
int a[N] ; 

int used = 0 ; 

vector<int> ans ; 

int dfs(int x , int val){
	if(a[x] > val){
		ans.push_back(val) ; 
		used ++ ; 
		assert(used < 2) ; 
		return x ; 
	}
	if(a[x] == val){	
		ans.push_back(val) ; 
		return x + 1 ; 
	}
	int ret1 = dfs(x , val - 1) ; 
	int ret2 = dfs(ret1 , val -1 ) ; 
	return ret2 ;  
}

int main(){
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ; 
	//freopen("in.in", "r" , stdin) ;

	cin >> n >> k ; 
	a[n] = (1<<30) ;
	for(int i = 0 ;i < n ; i++){
		cin >> a[i] ; 
	}

	dfs(0 , 30 ) ; 

	vector<int> ans2 ; 

	for(auto u : ans){
		ans2.push_back(u) ; 
		/*while(used < k && ans2.back() > 1){
			int x = ans2.back() ; 
			ans2.pop_back() ; 
			ans2.push_back(x-1) ; 
			ans2.push_back(x-1) ; 
			used ++ ; 
		}*/
	}
	reverse(ans2.begin() , ans2.end()) ;
	for(auto u : ans){
		cout<< u <<" " ; 
	}
	return 0 ; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 170 ms 14312 KB Output is correct
2 Correct 164 ms 14440 KB Output is correct
3 Correct 187 ms 14424 KB Output is correct
4 Correct 183 ms 14424 KB Output is correct
5 Correct 163 ms 14308 KB Output is correct
6 Correct 175 ms 14312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 84 ms 8440 KB Execution killed with signal 11
2 Runtime error 76 ms 8472 KB Execution killed with signal 11
3 Runtime error 84 ms 8568 KB Execution killed with signal 11
4 Runtime error 74 ms 8440 KB Execution killed with signal 11
5 Runtime error 74 ms 8440 KB Execution killed with signal 11
6 Runtime error 76 ms 8440 KB Execution killed with signal 11
7 Runtime error 100 ms 16616 KB Execution killed with signal 11
8 Runtime error 79 ms 9208 KB Execution killed with signal 11
9 Runtime error 57 ms 6904 KB Execution killed with signal 11
10 Runtime error 22 ms 2944 KB Execution killed with signal 11
11 Runtime error 36 ms 4488 KB Execution killed with signal 11
12 Runtime error 1 ms 512 KB Execution killed with signal 11
13 Runtime error 2 ms 512 KB Execution killed with signal 11
14 Runtime error 1 ms 512 KB Execution killed with signal 11