답안 #862112

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
862112 2023-10-17T14:16:40 Z iskhakkutbilim Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
317 ms 262148 KB
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
 
int n, k;
vector<pair<int, int> > ans;
int st[35];
vector<int> First[31];
int del, idx;
void f(int x, int depth){
	if(x < 0) return;
	int mn = 1;
	while(st[mn] <= 0 && 31 >= mn) mn++;
	if(mn > x){
		ans.push_back({x, 1});
		st[x]--;
		del++;
	}else if(First[x].empty() or First[x].back() + del > ans.size() + 1){
		f(x-1, depth + 1);
		f(x-1, depth + 1);
		
	}else if(First[x].back() + del <= ans.size() + 1){
		ans.push_back({x, 0});
		First[x].pop_back();
		st[x]--;
	}
	
}
 
 
 
 
 
main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for(int i = 0;i < n; i++){
		int x; cin >> x;
		st[x]++;
		First[x].push_back(i + 1);
	}
	for(int i = 1;i <= 30; i++){
		reverse(all(First[i]));
	}
	f(30, 1);
	
	for(auto [x, y] : ans) cout << x << ' ';
	return 0;
}

Compilation message

zalmoxis.cpp: In function 'void f(int, int)':
zalmoxis.cpp:21:53: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  }else if(First[x].empty() or First[x].back() + del > ans.size() + 1){
      |                               ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
zalmoxis.cpp:25:33: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  }else if(First[x].back() + del <= ans.size() + 1){
      |           ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
zalmoxis.cpp: At global scope:
zalmoxis.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 317 ms 262144 KB Execution killed with signal 9
2 Runtime error 309 ms 262144 KB Execution killed with signal 9
3 Runtime error 309 ms 262144 KB Execution killed with signal 9
4 Runtime error 316 ms 262144 KB Execution killed with signal 9
5 Runtime error 302 ms 262144 KB Execution killed with signal 9
6 Runtime error 304 ms 262148 KB Execution killed with signal 9
# 결과 실행 시간 메모리 Grader output
1 Runtime error 298 ms 262148 KB Execution killed with signal 9
2 Runtime error 310 ms 262144 KB Execution killed with signal 9
3 Runtime error 300 ms 262144 KB Execution killed with signal 9
4 Runtime error 298 ms 262144 KB Execution killed with signal 9
5 Runtime error 298 ms 262144 KB Execution killed with signal 9
6 Runtime error 302 ms 262144 KB Execution killed with signal 9
7 Runtime error 302 ms 262144 KB Execution killed with signal 9
8 Runtime error 302 ms 262144 KB Execution killed with signal 9
9 Runtime error 296 ms 262144 KB Execution killed with signal 9
10 Runtime error 282 ms 262144 KB Execution killed with signal 9
11 Runtime error 281 ms 262144 KB Execution killed with signal 9
12 Runtime error 261 ms 262144 KB Execution killed with signal 9
13 Runtime error 261 ms 262144 KB Execution killed with signal 9
14 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected