Submission #761773

#TimeUsernameProblemLanguageResultExecution timeMemory
761773Sohsoh84Jousting tournament (IOI12_tournament)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

template<
typename Key, // Key type
typename Mapped, // Mapped-policy
typename Cmp_Fn = std::less<Key>, // Key comparison functor
typename Tag = rb_tree_tag, // Specifies which underlying data structure to use
template<
typename Const_Node_Iterator,
typename Node_Iterator,
typename Cmp_Fn_,
typename Allocator_>
class Node_Update = null_node_update, // A policy for updating node invariants
typename Allocator = std::allocator<char> > // An allocator type
class tree;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int MAXN = 1e6 + 10;

int n;

int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
	n = N;
	vector<int> bst;
	for (int i = 0; i < n - 1; i++)
		if (K[i] > R)
			bst.push_back(i);

	ordered_set pst;
	for (int i = 0; i <= n; i++)
		pst.insert(i);

	set<int> opt;
	for (int i = 0; i < n; i++)
		opt.insert(i);

	int ans = 0;

	for (int i = 0; i < C; i++) {
		int tl = S[i] + 1, tr = E[i];
		int l = *pst.find_by_order(tl), r = *pst.find_by_order(tr + 1) - 1;
		if (l == r) continue;
		
		while (*pst.upper_bound(l) <= r) 
			pst.erase(pst.upper_bound(l));

		auto it = lower_bound(all(bst), l);
		if (it != bst.end() && *it <= r - 1) {
			if (opt.lower_bound(l) != opt.end() && *opt.lower_bound(l) <= r) 
				ans = *opt.lower_bound(l);
			while (opt.lower_bound(l) != opt.end() && *opt.lower_bound(l) <= r) 
				opt.erase(opt.lower_bound(l));
		}
	}

	if (!opt.empty())
		ans = *opt.begin();
	return 0;
}

Compilation message (stderr)

tournament.cpp: In function 'int GetBestPosition(int, int, int, int*, int*, int*)':
tournament.cpp:40:14: error: aggregate 'ordered_set pst' has incomplete type and cannot be defined
   40 |  ordered_set pst;
      |              ^~~
tournament.cpp:53:12: error: 'r' was not declared in this scope
   53 |   if (l == r) continue;
      |            ^
tournament.cpp:55:33: error: 'r' was not declared in this scope
   55 |   while (*pst.upper_bound(l) <= r)
      |                                 ^
tournament.cpp:58:25: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   58 |   auto it = lower_bound(all(bst), l);
      |                         ^~~
      |                         std::filesystem::perms::all
In file included from /usr/include/c++/10/filesystem:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from tournament.cpp:1:
/usr/include/c++/10/bits/fs_fwd.h:148:7: note: 'std::filesystem::perms::all' declared here
  148 |       all  =  0777,
      |       ^~~
tournament.cpp:59:33: error: 'r' was not declared in this scope
   59 |   if (it != bst.end() && *it <= r - 1) {
      |                                 ^
tournament.cpp:51:22: warning: unused variable 'tr' [-Wunused-variable]
   51 |   int tl = S[i] + 1, tr = E[i];
      |                      ^~