QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#47054#4563. Radio TowerszhoukangyangCompile Error//C++111.1kb2022-09-03 16:27:002022-09-03 16:27:01

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-03 16:27:01]
  • 评测
  • [2022-09-03 16:27:00]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i) 
#define R(i, j, k) for(int i = (j); i >= (k); --i) 
#define ll long long 
#define vi vector < int > 
#define sz(a) ((int) (a).size())
#define me(a, x) memset(a, x, sizeof(a))
using namespace std;
const int N = 1e6 + 7;
int n, a[N];
int d, ch[N][2], mn[N], ns;
void init(int xn, vi A) {
	n = xn, mn[0] = 1e9;
	L(i, 1, n) a[i] = A[i - 1];
}

void dfs(int x) {
	mn[x] = a[x];
	L(a, 0, 1) if(ch[x][a]) dfs(ch[x][a]), mn[x] = min(mn[x], mn[ch[x][a]]);
	ns += max(mn[ch[x][0]], mn[ch[x][1]]) <= a[x] - d;
}

int stk[N], top;
int max_towers(int l, int r, int D) {
	++l, ++r, d = D, top = 0;
	L(i, 1, n) stk[i] = ch[i][0] = ch[i][1] = 0;
	L(i, l, r) {
		int las = top;
		while(top && a[stk[top]] < a[i]) -- top;
		if(top > 0) ch[stk[top]][1] = i;
		if(top != las) ch[i][0] = stk[top + 1];
		stk[++top] = i;
	}
	ns = 1;
	dfs(stk[1]);
	return ns;
}
int main() {
	init(7, vi{10, 20, 60, 40, 50, 30, 70});
	cout << max_towers(1, 5, 10) << '\n';
	cout << max_towers(2, 2, 100) << '\n';
	cout << max_towers(0, 6, 17) << '\n';
	return 0;
}

Details

/tmp/cc8l6b8A.o: In function `main':
answer.code:(.text.startup+0x0): multiple definition of `main'
/tmp/ccENQT31.o:implementer.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status