답안 #674774

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
674774 2022-12-26T07:43:13 Z Valera_Grinenko 비밀 (JOI14_secret) C++17
컴파일 오류
0 ms 0 KB
#include "secret.h"
#include <vector>
using namespace std;

template<class T> struct offlineDQ {
  const int SZ = (1 << 10)
  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;
    for(int i = m - 1; i >= l; i--) stor[i][ind] = prod = comb(a[i],prod);
		prod = id;
    for(int i = m; i < r; i++) 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> 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:8:10: error: invalid use of non-static data member 'offlineDQ<T>::SZ'
    8 |   T stor[SZ][32-__builtin_clz(SZ)], id = 1;
      |          ^~
secret.cpp:6:13: note: declared here
    6 |   const int SZ = (1 << 10)
      |             ^~
secret.cpp:8:31: error: invalid use of non-static data member 'offlineDQ<T>::SZ'
    8 |   T stor[SZ][32-__builtin_clz(SZ)], id = 1;
      |                               ^~
secret.cpp:6:13: note: declared here
    6 |   const int SZ = (1 << 10)
      |             ^~
secret.cpp:7:3: error: expected ';' before 'int'
    7 |   int n;
      |   ^~~
secret.cpp: In member function 'void offlineDQ<T>::fill(int, int, int)':
secret.cpp:15:37: error: 'stor' was not declared in this scope
   15 |     for(int i = m - 1; i >= l; i--) stor[i][ind] = prod = comb(a[i],prod);
      |                                     ^~~~
secret.cpp:17:32: error: 'stor' was not declared in this scope
   17 |     for(int i = m; i < r; i++) stor[i][ind] = prod = comb(prod,a[i]);
      |                                ^~~~
secret.cpp: In member function 'void offlineDQ<T>::init(int)':
secret.cpp:21:3: error: 'n' was not declared in this scope
   21 |   n = 1; while ((1<<n) < sz(a)) ++n;
      |   ^
secret.cpp: In member function 'T offlineDQ<T>::query(int, int)':
secret.cpp:27:15: error: 'stor' was not declared in this scope
   27 |   return comb(stor[l][t],stor[r][t]);
      |               ^~~~
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:35:12: error: no matching function for call to 'offlineDQ<int>::init()'
   35 |   odq.init();
      |            ^
secret.cpp:20:7: note: candidate: 'void offlineDQ<T>::init(int) [with T = int]'
   20 |  void init(int N) {
      |       ^~~~
secret.cpp:20:7: note:   candidate expects 1 argument, 0 provided
secret.cpp: In function 'int Query(int, int)':
secret.cpp:39:10: error: 'odq' was not declared in this scope
   39 |   return odq.query(--L, --R);
      |          ^~~