Submission #1210489

#TimeUsernameProblemLanguageResultExecution timeMemory
1210489banganSplit the Attractions (IOI19_split)C++20
Compilation error
0 ms0 KiB
#include "split.h"
using namespace std;

#define X first 
#define Y second
#define pair pair<int, int>

#define pb push_back
#define all(a) a.begin(), a.end()

const int N = 2e5 + 4;

vector<int> adj[N];
vector<vector<int>> V;
bool vis[N];

void dfs(int v) {
	vis[v]=1;
	V.back().pb(v);
	for (int u : adj[v]) if (!vis[u]) dfs(u);
}

vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
	for (int i=0; i<p.size(); i++) {
		adj[p[i]].pb(q[i]);
		adj[q[i]].pb(p[i]);
	}
	for (int i=0; i<n; i++) if (!vis[i]) {
		V.pb({});
		dfs(i);
	}
	vector<pair> ord{{a,1}, {b,2}, {c,3}};
	sort(all(ord), greater<pair>());
	sort(all(V), [&](auto &x, auto &y) {
		return x.size()<y.size();
	});
	vector<int> ans(n);
	int rep=2;
	while (rep--) {
		for (auto &vec : V) if (vec.size() >= ord.back().X) {
			int t = ord.back().X;
			while (t--) {
				int v = vec.back();
				ans[v] = ord.back().Y;
				vec.pop_back();
			}
			ord.pop_back();
			break;
		}
	}
	if (ord.size()>1) return vector(n, 0);
	for (int i=0; i<n; i++) if (!ans[i]) ans[i] = ord.back().Y;
	return ans;
}

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:33:24: error: 'greater' was not declared in this scope
   33 |         sort(all(ord), greater<pair>());
      |                        ^~~~~~~~~~~~~
split.cpp:33:24: note: suggested alternatives:
In file included from /usr/include/c++/11/bits/iterator_concepts.h:37,
                 from /usr/include/c++/11/bits/stl_iterator_base_types.h:71,
                 from /usr/include/c++/11/bits/stl_algobase.h:65,
                 from /usr/include/c++/11/vector:60,
                 from split.h:5,
                 from split.cpp:1:
/usr/include/c++/11/bits/ranges_cmp.h:140:10: note:   'std::ranges::greater'
  140 |   struct greater
      |          ^~~~~~~
In file included from /usr/include/c++/11/bits/stl_pair.h:65,
                 from /usr/include/c++/11/bits/stl_algobase.h:64,
                 from /usr/include/c++/11/vector:60,
                 from split.h:5,
                 from split.cpp:1:
/usr/include/c++/11/compare:53:57: note:   'std::__cmp_cat::_Ord::greater'
   53 |     enum class _Ord : type { equivalent = 0, less = -1, greater = 1 };
      |                                                         ^~~~~~~