Submission #390857

# Submission time Handle Problem Language Result Execution time Memory
390857 2021-04-17T08:57:58 Z hhhhaura Secret (JOI14_secret) C++14
100 / 100
573 ms 4432 KB
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)

#define rep(i, a, b) for(int i = a; i <= b; i++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))
#define INF 1e9
#define MAXN 2000

using namespace std;

int n, b[100][MAXN], a[MAXN];
int Secret(int, int);
void build(int d, int L, int R) {
	if(L == R) b[d][L] = a[L];
	else {
		int mid = (L + R) / 2;
		build(d + 1, L, mid);
		build(d + 1, mid + 1, R);
		b[d][mid] = a[mid];
		b[d][mid + 1] = a[mid + 1];
		rrep(i, L, mid - 1) b[d][i] = Secret(a[i], b[d][i + 1]);			
		rep(i, mid + 2, R) b[d][i] = Secret(b[d][i - 1], a[i]);
	}
}
int query(int d, int L, int R, int l, int r) {
	int mid = (L + R) / 2;
	if(l > R || r < L) return INF;
	else if(L == R) return b[d][l];
	else if(l <= mid && r >= mid + 1) 
		return Secret(b[d][l], b[d][r]);
	else {
		int aa = query(d + 1, L, mid, l, r);
		int bb = query(d + 1, mid + 1, R, l, r);
		if(aa > bb) return bb;
		return aa;
	}
}
void Init(int N, int A[]) {
	n = N;
	rep(i, 0, n - 1) a[i] = A[i];
	build(1, 0, n - 1);
	return;
}
int Query(int L, int R) {
	return query(1, 0, n - 1, L, R);
}

Compilation message

secret.cpp:2: warning: ignoring #pragma loop  [-Wunknown-pragmas]
    2 | #pragma loop-opt(on)
      |
# Verdict Execution time Memory Grader output
1 Correct 143 ms 2364 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 144 ms 2432 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 142 ms 2480 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 507 ms 4420 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 534 ms 4360 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 506 ms 4432 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 573 ms 4256 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 509 ms 4276 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 509 ms 4412 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 512 ms 4264 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1