Submission #396612

# Submission time Handle Problem Language Result Execution time Memory
396612 2021-04-30T12:39:14 Z Aryan_Raina Secret (JOI14_secret) C++14
6 / 100
559 ms 4460 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

template<class T, int SZ> struct RangeQuery {
	int n; 
	T stor[SZ][31-__builtin_clz(SZ)], id = 1;
	vector<T> a;
	T comb(T a, T b) { return Secret(a, b); }
	void fill(int l, int r, int ind) {
		if (ind < 0) return;
		int m = (l + r) >> 1;
		T pre = stor[m-1][ind] = a[m-1]; 
		for (int i = m-2; i >= l; i--) stor[i][ind] = pre = comb(a[i], pre);
		pre = stor[m][ind] = a[m]; 
		for (int i = m+1; i < r; i++) stor[i][ind] = pre = comb(pre, a[i]);
		fill(l, m, ind-1); fill(m, r, ind-1);
	}	
	void init() {
		n = 1; while ((1<<n) < a.size()) n++;
		a.resize(1<<n); fill(0, 1<<n, n-1);
	}
	T query(int l, int r) {
		if (l == r) return a[l];
		int t = 31-__builtin_clz(r^l);
		return comb(stor[l][t], stor[r][t]);
	}
};

RangeQuery<int, (1<<10)> rq;
void Init(int N, int A[]) {
	rq.a.resize(N);
	for (int i = 0; i < N; i++) {
		rq.a[i] = A[i];
	}
	rq.init();
}

int Query(int L, int R) {
  return rq.query(L, R);
}

Compilation message

secret.cpp: In instantiation of 'void RangeQuery<T, SZ>::init() [with T = int; int SZ = 1024]':
secret.cpp:36:10:   required from here
secret.cpp:20:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   n = 1; while ((1<<n) < a.size()) n++;
# Verdict Execution time Memory Grader output
1 Correct 143 ms 2380 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
2 Correct 140 ms 2392 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Partially correct 141 ms 2380 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
4 Partially correct 502 ms 4400 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
5 Partially correct 516 ms 4328 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
6 Partially correct 502 ms 4340 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
7 Partially correct 498 ms 4292 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
8 Partially correct 500 ms 4284 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
9 Partially correct 499 ms 4460 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
10 Partially correct 559 ms 4396 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1