Submission #862114

# Submission time Handle Problem Language Result Execution time Memory
862114 2023-10-17T14:17:49 Z iskhakkutbilim Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
1000 ms 7592 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[35];
int del, idx;
void f(int x, int depth){
	if(x < 0) return;
	int mn = 0;
	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(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1039 ms 6940 KB Time limit exceeded
2 Execution timed out 1060 ms 6988 KB Time limit exceeded
3 Execution timed out 1065 ms 7064 KB Time limit exceeded
4 Execution timed out 1058 ms 6864 KB Time limit exceeded
5 Execution timed out 1054 ms 6824 KB Time limit exceeded
6 Execution timed out 1060 ms 6820 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1054 ms 7068 KB Time limit exceeded
2 Execution timed out 1062 ms 7028 KB Time limit exceeded
3 Execution timed out 1052 ms 7144 KB Time limit exceeded
4 Execution timed out 1032 ms 7592 KB Time limit exceeded
5 Execution timed out 1095 ms 6944 KB Time limit exceeded
6 Execution timed out 1060 ms 7232 KB Time limit exceeded
7 Execution timed out 1064 ms 7072 KB Time limit exceeded
8 Execution timed out 1051 ms 6936 KB Time limit exceeded
9 Execution timed out 1067 ms 5744 KB Time limit exceeded
10 Execution timed out 1059 ms 2652 KB Time limit exceeded
11 Execution timed out 1022 ms 3848 KB Time limit exceeded
12 Execution timed out 1057 ms 348 KB Time limit exceeded
13 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
14 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected