Submission #72117

# Submission time Handle Problem Language Result Execution time Memory
72117 2018-08-26T05:22:21 Z @younha_holic(#2227, jun6873, rkm0959) Box Run (FXCUP3_box) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1<<19;
int n, a[maxn], b[maxn];

typedef pair<int, int> pint;
#define x first
#define y second

void xfill(int s, int e, int l, int r) {
	if (s>e) return;
	int m = (s+e)/2, k = max(m, l);

	deque<pint> dq;
	for (int i=k-m+1; i<=k; i++) {
		while (!dq.empty() and dq.back().x < a[i]) dq.pop_back();
		dq.emplace_back(a[i], i);
	}
	while (k+1<=r) {
		pint x = dq.front();
		if (a[k+1] > x.x) break;
		k++;
		if (dq.front().y < k-m+1) dq.pop_front();
		while (!dq.empty() and dq.back().x < a[k]) dq.pop_back();
		dq.emplace_back(a[k], k);
	}
	if (k>r) k = r;
	b[m] = k;

	if (s<e) {
		int m = (s+e)/2;
		xfill(s, m-1, l, k);
		xfill(m+1, e, k, r);
	}
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> n;
	for (int i=1; i<=n; i++) cin >> a[i];
	for (int i=1; i<=n; i++) t.update(i, a[i]);

	xfill(1, n, 1, n);

	for (int i=1; i<=n; i++) {
		if (b[i] == n) cout << -1 << ' ';
		else cout << b[i] - i + 1 << ' ';
	}

}

Compilation message

box.cpp: In function 'int main()':
box.cpp:43:27: error: 't' was not declared in this scope
  for (int i=1; i<=n; i++) t.update(i, a[i]);
                           ^