제출 #396618

#제출 시각아이디문제언어결과실행 시간메모리
396618Aryan_Raina비밀 (JOI14_secret)C++14
100 / 100
520 ms5444 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; map<pair<int,int>, int> mp; 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) { if (mp.count({a, b})) return mp[{a,b}]; if (mp.count({b, a})) return mp[{b,a}]; return mp[{a,b}] = 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); }

컴파일 시 표준 에러 (stderr) 메시지

secret.cpp: In instantiation of 'void RangeQuery<T, SZ>::init() [with T = int; int SZ = 1024]':
secret.cpp:41:10:   required from here
secret.cpp:25:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   n = 1; while ((1<<n) < a.size()) n++;
#Verdict Execution timeMemoryGrader output
Fetching results...