Submission #1312887

#TimeUsernameProblemLanguageResultExecution timeMemory
1312887ghammazhassanSecret (JOI14_secret)C++20
100 / 100
344 ms12264 KiB
#include "secret.h" #include <iostream> #include <cmath> #include <algorithm> #include <map> #include <unordered_map> #include <vector> #include <iomanip> #include <string> #include <queue> #include <set> #include <deque> #define MAX_N 1000 #define MAX_Q 10000 #define MAX_VALUE 1000000000 using namespace std; static int N; static int A[MAX_N]; static int Q; static int L[MAX_Q]; static int R[MAX_Q]; static int secret_count; const int NN=1e3+5; const int LOG=10; int st[NN][NN]; int vi[NN][NN]; int nn; void bin(int l,int h){ int m=(l+h)/2; if (h-l<=1)return; for (int i=m-1;i>=l;i--){ if (vi[i][m])continue; st[i][m]=Secret(st[i][i],st[i+1][m]); vi[i][m]=1; } for (int i=m+2;i<=h;i++){ if (vi[m+1][i])continue; st[m+1][i]=Secret(st[m+1][i-1],st[i][i]); vi[m+1][i]=1; } bin(l,m); bin(m+1,h); } void Init(int n,int a[]){ nn=n; for (int i=0;i<n;i++){ st[i][i]=a[i]; vi[i][i]=1; } bin(0,n-1); } int Query(int L,int R){ if (vi[L][R])return st[L][R]; for (int i=L;i<R;i++){ if (vi[L][i] and vi[i+1][R]){ return Secret(st[L][i],st[i+1][R]); } } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...