Submission #656565

#TimeUsernameProblemLanguageResultExecution timeMemory
656565socpiteSecret (JOI14_secret)C++14
0 / 100
20096 ms4468 KiB
#include "secret.h" #include<bits/stdc++.h> using namespace std; #define f first #define s second typedef long long ll; const int maxn = 1005; vector<int> pfx[4*maxn], sfx[4*maxn]; int arr[maxn]; int n; void build(int l, int r, int id){ if(r-l<=1)return; int mid = (l+r)>>1; pfx[id].resize(r-mid); sfx[id].resize(mid+1-l); pfx[id][0]=arr[mid+1]; sfx[id][0]=arr[mid]; for(int i = mid+2; i <= r; i++){ pfx[id][i-mid-1]=Secret(pfx[id][i-mid-2], arr[i]); } for(int i = 1; i < sfx[id].size(); i++){ sfx[id][i]=Secret(arr[mid-i], sfx[id][i-1]); } build(l, mid, id<<1); build(mid+1, r, id<<1|1); } int gt(int l, int r, int ql, int qr, int id){ int mid = (l+r)>>1; if(qr < mid)return gt(l, r, ql, qr, id<<1); else if(ql > mid+1)return gt(mid+1, r, ql, qr, id<<1|1); else{ int re = -1; if(ql <= mid)re = sfx[id][mid-ql]; if(qr >= mid+1){ if(re < 0)re = pfx[id][qr-mid-1]; else re = Secret(re, pfx[id][qr-mid-1]); } return re; } } int Query(int L, int R){ if(L==R)return arr[L]; else if(R-1==L)return Secret(arr[L], arr[R]); else return gt(0, n-1, L, R, 1); } void Init(int N, int A[]){ n = N; for(int i = 0; i < n; i++)arr[i]=A[i]; build(0, n-1, 1); }

Compilation message (stderr)

secret.cpp: In function 'void build(int, int, int)':
secret.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 1; i < sfx[id].size(); i++){
      |                    ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...