Submission #683887

# Submission time Handle Problem Language Result Execution time Memory
683887 2023-01-19T14:38:16 Z amukkalir Secret (JOI14_secret) C++17
30 / 100
522 ms 4508 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std; 

const int nax = 1e3;
int tree[2][4*nax+5];
int a[nax+5]; 
int n; 
void build(int x, int l=0, int r=n-1, int idx=1){
  if (l == r) {
    tree[x][idx] = a[l+x]; 
  } else {
    int m = (l+r)>>1; 
    build(x,l,m,idx<<1);
    build(x,m+1,r,idx<<1|1); 
    tree[x][idx] = Secret(tree[x][idx<<1], tree[x][idx<<1|1]); 
  }
}

int get(int x, int fr, int to, int l=0, int r=n-1, int idx=1) {
  if (fr <= l && r <= to) return tree[x][idx];
  else {
    int m = (l+r)>>1; 
    if (fr > m) {
      return get(x, fr, to, m+1, r, idx<<1|1); 
    } else if (to <= m) {
      return get(x, fr, to, l, m, idx<<1); 
    } else {
      //cerr << x << " " << fr << " " << to << " "<<l<<" " << r<<endl;
      int res = Secret(get(x, fr, to, l, m, idx<<1), get(x, fr, to, m+1, r, idx<<1|1)); 
      //cerr << l << " " << r << " " << res << endl; 
      return res; 
    }
  }
}



void Init(int N, int A[]) {
  n=N; 
  for(int i=0; i<N; i++) a[i] = A[i]; 
  build(0); //build(1); 
}

int Query(int L, int R) {
  return get(0,L,R);
  return get(L%2,L-(L%2),R-(L%2));
}
# Verdict Execution time Memory Grader output
1 Partially correct 191 ms 2280 KB Output is partially correct - number of calls to Secret by Init = 510, maximum number of calls to Secret by Query = 13
2 Partially correct 172 ms 2284 KB Output is partially correct - number of calls to Secret by Init = 511, maximum number of calls to Secret by Query = 14
3 Partially correct 162 ms 2384 KB Output is partially correct - number of calls to Secret by Init = 512, maximum number of calls to Secret by Query = 15
4 Partially correct 490 ms 4348 KB Output is partially correct - number of calls to Secret by Init = 998, maximum number of calls to Secret by Query = 15
5 Partially correct 490 ms 4284 KB Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 15
6 Partially correct 442 ms 4276 KB Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 4
7 Partially correct 506 ms 4508 KB Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16
8 Partially correct 508 ms 4332 KB Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16
9 Partially correct 522 ms 4288 KB Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16
10 Partially correct 497 ms 4216 KB Output is partially correct - number of calls to Secret by Init = 999, maximum number of calls to Secret by Query = 16