제출 #1135965

#제출 시각아이디문제언어결과실행 시간메모리
1135965huutuan비밀 (JOI14_secret)C++20
0 / 100
341 ms8360 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; const int N=1010; int val[N][N], n, a[N]; void Init(int _n, int _a[]) { n=_n; for (int i=0; i<n; ++i) a[i]=_a[i]; auto dnc=[&](auto &&self, int l, int r) -> void { if (l>=r) return; int mid=(l+r)>>1; val[mid][mid]=a[mid]; for (int i=mid+1; i<=r; ++i){ val[mid][i]=Secret(val[mid][i-1], a[i]); } if (mid){ val[mid-1][mid-1]=a[mid-1]; for (int i=mid-1; i>=l; --i){ val[i][mid-1]=Secret(a[i], val[i+1][mid-1]); } } self(self, l, mid-2); self(self, mid+1, r); }; dnc(dnc, 0, n-1); } int Query(int L, int R) { if (L==R) return a[L]; auto dnc=[&](auto &&self, int l, int r) -> int { if (l>=r) assert(false); int mid=(l+r)>>1; if (L<mid && mid<=R){ return Secret(val[L][mid-1], val[mid][R]); } if (L==mid || mid-1==R) return val[L][R]; if (R<mid) return self(self, l, mid-2); return self(self, mid+1, r); }; return dnc(dnc, 0, n-1); }
#Verdict Execution timeMemoryGrader output
Fetching results...