Submission #674771

# Submission time Handle Problem Language Result Execution time Memory
674771 2022-12-26T07:40:01 Z Valera_Grinenko Secret (JOI14_secret) C++17
Compilation error
0 ms 0 KB
#include "secret.h"
#include <vector>

template<class T, int SZ> struct offlineDQ {
  int n;
  T stor[SZ][32-__builtin_clz(SZ)], id = 1;
	vector<T> a;
	T comb (T a, T b) { return Secret(a, b); } // associative operation
	void fill(int l, int r, int ind) {
		if (ind < 0) return;
		int m = (l+r)/2;
		T prod = id; ROF(i,l,m) stor[i][ind] = prod = comb(a[i],prod);
		prod = id; FOR(i,m,r) stor[i][ind] = prod = comb(prod,a[i]);
		fill(l,m,ind-1); fill(m,r,ind-1);
	}
	void init(int N) {
		n = 1; while ((1<<n) < sz(a)) ++n;
		a.rsz(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]);
	}
};

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

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

Compilation message

secret.cpp:7:2: error: 'vector' does not name a type
    7 |  vector<T> a;
      |  ^~~~~~
secret.cpp: In member function 'void offlineDQ<T, SZ>::fill(int, int, int)':
secret.cpp:12:20: error: 'i' was not declared in this scope
   12 |   T prod = id; ROF(i,l,m) stor[i][ind] = prod = comb(a[i],prod);
      |                    ^
secret.cpp:12:16: error: there are no arguments to 'ROF' that depend on a template parameter, so a declaration of 'ROF' must be available [-fpermissive]
   12 |   T prod = id; ROF(i,l,m) stor[i][ind] = prod = comb(a[i],prod);
      |                ^~~
secret.cpp:12:16: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
secret.cpp:12:26: error: expected ';' before 'stor'
   12 |   T prod = id; ROF(i,l,m) stor[i][ind] = prod = comb(a[i],prod);
      |                          ^~~~~
      |                          ;
secret.cpp:13:14: error: there are no arguments to 'FOR' that depend on a template parameter, so a declaration of 'FOR' must be available [-fpermissive]
   13 |   prod = id; FOR(i,m,r) stor[i][ind] = prod = comb(prod,a[i]);
      |              ^~~
secret.cpp:13:24: error: expected ';' before 'stor'
   13 |   prod = id; FOR(i,m,r) stor[i][ind] = prod = comb(prod,a[i]);
      |                        ^~~~~
      |                        ;
secret.cpp: In member function 'void offlineDQ<T, SZ>::init(int)':
secret.cpp:17:29: error: 'a' was not declared in this scope
   17 |   n = 1; while ((1<<n) < sz(a)) ++n;
      |                             ^
secret.cpp:17:26: error: there are no arguments to 'sz' that depend on a template parameter, so a declaration of 'sz' must be available [-fpermissive]
   17 |   n = 1; while ((1<<n) < sz(a)) ++n;
      |                          ^~
secret.cpp:18:3: error: 'a' was not declared in this scope
   18 |   a.rsz(1<<n); fill(0,(1<<n),n-1);
      |   ^
secret.cpp: In member function 'T offlineDQ<T, SZ>::query(int, int)':
secret.cpp:21:22: error: 'a' was not declared in this scope
   21 |   if (l == r) return a[l];
      |                      ^
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:28:19: error: 'N' is not a constant expression
   28 |   offlineDQ<int, N> odq;
      |                   ^
secret.cpp:28:19: note: in template argument for type 'int'
secret.cpp:29:7: error: request for member 'a' in 'odq', which is of non-class type 'int'
   29 |   odq.a.resize(N);
      |       ^
secret.cpp:30:34: error: request for member 'a' in 'odq', which is of non-class type 'int'
   30 |   for(int i = 0; i < N; i++) odq.a[i] = A[i];
      |                                  ^
secret.cpp:31:7: error: request for member 'init' in 'odq', which is of non-class type 'int'
   31 |   odq.init();
      |       ^~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:35:10: error: 'odq' was not declared in this scope
   35 |   return odq.query(--L, --R);
      |          ^~~