Submission #227132

#TimeUsernameProblemLanguageResultExecution timeMemory
227132arnold518Secret (JOI14_secret)C++14
0 / 100
517 ms4680 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1000; int N, A[MAXN+10]; int tree[MAXN+10][30]; void init(int node, int tl, int tr, int dep) { int i, j; int mid=tl+tr>>1; tree[mid][dep]=A[mid]; for(i=mid-1; i>=tl; i--) tree[i][dep]=Secret(A[i], tree[i+1][dep]); tree[mid+1][dep]=A[mid+1]; for(i=mid+2; i<=tr; i++) tree[i][dep]=Secret(tree[i-1][dep], A[i]); if(tl==tr) return; init(node*2, tl, mid, dep+1); init(node*2+1, mid+1, tr, dep+1); } int query(int node, int tl, int tr, int l, int r, int dep) { int mid=tl+tr>>1; if(tl<=l && r<=tr) return Secret(tree[l][dep], tree[r][dep]); if(r<=mid) return query(node*2, tl, mid, l, r, dep+1); if(mid+1<=l) return query(node*2+1, mid+1, tr, l, r, dep+1); } void Init(int _N, int _A[]) { int i, j; N=_N; for(i=1; i<=N; i++) A[i]=_A[i-1]; init(1, 1, N, 1); } int Query(int L, int R) { L++; R++; if(L==R) return A[L]; return query(1, 1, N, L, R, 1); }

Compilation message (stderr)

secret.cpp: In function 'void init(int, int, int, int)':
secret.cpp:18:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid=tl+tr>>1;
          ~~^~~
secret.cpp:16:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
secret.cpp: In function 'int query(int, int, int, int, int, int)':
secret.cpp:32:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid=tl+tr>>1;
          ~~^~~
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:40:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
secret.cpp: In function 'int query(int, int, int, int, int, int)':
secret.cpp:36:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...