Submission #502709

# Submission time Handle Problem Language Result Execution time Memory
502709 2022-01-06T13:24:22 Z sidon Minerals (JOI19_minerals) C++17
Compilation error
0 ms 0 KB
#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;

const int LIM = 43e3;

int A[LIM], L, R = -1, last;

#define ask(Z) (last = Query(Z))

void dfs(int l, int r, vector<int> b, bool on) {
	if(r - l < 1) return;
	if(r - l < 2) return Answer(A[l], b[0]);

	int m = (l + r) / 2;
	if(l < m-1 && m - l == r - m) --m;
	if(l < m-1 && m - l + 1 == r - m) --m;
	if(l < m-1 && m - l + 2 == r - m) --m;

	for(int i = l; i < m; ++i)
		ask(A[i]);

	vector<int> bL, bR;

	for(int &i : b) {
		if((int)size(bL) == m - l) {
			bR.push_back(i);
			continue;
		}
		if((int)size(bR) == r - m) {
			bL.push_back(i);
			continue;
		}
		int prev = last;
		((prev == ask(i)) ^ on ? bL : bR).push_back(i);
	}

	dfs(l, m, bL, on ^ 1);
	dfs(m, r, bR, on);
}

void Solve(int N) {

	array<int, 2> s[N+N];
	
	{
		struct timeval tv;
		mingw_gettimeofday(&tv, NULL);
		unsigned int i = 0, j = (tv.tv_sec ^ tv.tv_usec) | 1;

		for(; int(i) < N + N; ++i)
			s[i] = {int((j *= 3) >> 1), int(i)+1};
	}
	sort(s, s+N+N);

	vector<int> b;

	for(auto &[_, i] : s) {
		if(R == N - 1 || ask(i) < R + 2) {
			b.push_back(i);
		} else A[++R] = i;
	}
	dfs(0, N, b, 1);
}

Compilation message

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:48:3: error: 'mingw_gettimeofday' was not declared in this scope
   48 |   mingw_gettimeofday(&tv, NULL);
      |   ^~~~~~~~~~~~~~~~~~