Submission #250102

# Submission time Handle Problem Language Result Execution time Memory
250102 2020-07-17T03:01:58 Z shenxy Minerals (JOI19_minerals) C++14
Compilation error
0 ms 0 KB
#include "minerals.h"
#include <algorithm>
#include <vector>
using namespace std;
vector<int> firsts, ans;
int lquery = 0;
void recurse(vector<int> &v, int l, int r, bool has = true) {
	if (l != r) {
		int m = (l + r) / 2;
		for (int i = l; i <= m; ++i) lquery = Query(firsts[i]);
		vector<int> a, b;
		for (int i: v) {
			if (a.size() != m - l + 1 && b.size) != r - m) {
				int x = Query(i);
				if (has == (x != lquery)) a.push_back(i);
				else b.push_back(i);
				if (x != lquery) lquery = x;
			} else if (a.size() != m - l + 1) a.push_back(i);
			else b.push_back(i);
		}
		recurse(a, l, m, !has);
		recurse(b, m + 1, r, has);
	} else ans.push_back(v[0]);
}
void Solve(int N) {
	vector<int> duds;
	for (int i = 1; i <= 2 * N; ++i) {
		int x = Query(i);
		if (x != lquery) firsts.push_back(i), lquery = x;
		else duds.push_back(i);
	}
	recurse(duds, 0, N - 1);
	for (int i = 0; i < N; ++i) Answer(firsts[i], ans[i]);
}

Compilation message

minerals.cpp: In function 'void recurse(std::vector<int>&, int, int, bool)':
minerals.cpp:13:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (a.size() != m - l + 1 && b.size) != r - m) {
        ~~~~~~~~~^~~~~~~~~~~~
minerals.cpp:13:35: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' (did you forget the '()' ?)
    if (a.size() != m - l + 1 && b.size) != r - m) {
                                 ~~^~~~
minerals.cpp:13:41: error: expected primary-expression before '!=' token
    if (a.size() != m - l + 1 && b.size) != r - m) {
                                         ^~
minerals.cpp:18:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    } else if (a.size() != m - l + 1) a.push_back(i);
               ~~~~~~~~~^~~~~~~~~~~~