Submission #525543

# Submission time Handle Problem Language Result Execution time Memory
525543 2022-02-11T22:07:53 Z omohamadooo Secret (JOI14_secret) C++14
Compilation error
0 ms 0 KB
#include "secret.h"
#include "bits/stdc++.h"
using namespace std;

int n;
int v[N];
int pref[4020][1005],suf[4020][1005];

int ask(int a, int b){
	return Secret(a, b);
}

void build(ll lx,ll rx,int x)
{
    if(lx == rx) return;
    ll m = (lx + rx)/2;
    pref[x][m] = v[m];
    for(int p=m-1;p>=lx;p--){
        pref[x][p] = ask(v[p], pref[x][p+1]);
    }

    suff[x][m+1] = v[m+1];
    for(int p=m+2;p<=rx;p++){
        suff[x][p] = ask(suff[x][p-1], v[p]);
    }
    build(lx, m, x<<1);
    build(m+1, rx, x<<1|1);
}

void Init(int f , int a[])
{
    n = f;
    for(ll i=0;i<n;i++) v[i] = a[i];
    build(0,0,n-1);
}

int get(int l, int r, int lx, int rx, int x){
    if(lx == rx) return v[lx];
    int m = (lx + rx) >> 1;
    if(r <= m) return get(l, r, lx, m, x<<1);
    if(m < l) return get(l, r, m+1, rx, x<<1|1);
    return ask(pref[x][l], suff[x][r]);
}

int Query(int l, int r)
{
    return get(l,r , 0,n-1,1);
}

Compilation message

secret.cpp:6:7: error: 'N' was not declared in this scope
    6 | int v[N];
      |       ^
secret.cpp:13:6: error: variable or field 'build' declared void
   13 | void build(ll lx,ll rx,int x)
      |      ^~~~~
secret.cpp:13:12: error: 'll' was not declared in this scope
   13 | void build(ll lx,ll rx,int x)
      |            ^~
secret.cpp:13:18: error: 'll' was not declared in this scope
   13 | void build(ll lx,ll rx,int x)
      |                  ^~
secret.cpp:13:24: error: expected primary-expression before 'int'
   13 | void build(ll lx,ll rx,int x)
      |                        ^~~
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:33:9: error: 'll' was not declared in this scope
   33 |     for(ll i=0;i<n;i++) v[i] = a[i];
      |         ^~
secret.cpp:33:16: error: 'i' was not declared in this scope
   33 |     for(ll i=0;i<n;i++) v[i] = a[i];
      |                ^
secret.cpp:33:25: error: 'v' was not declared in this scope
   33 |     for(ll i=0;i<n;i++) v[i] = a[i];
      |                         ^
secret.cpp:34:5: error: 'build' was not declared in this scope
   34 |     build(0,0,n-1);
      |     ^~~~~
secret.cpp: In function 'int get(int, int, int, int, int)':
secret.cpp:38:25: error: 'v' was not declared in this scope
   38 |     if(lx == rx) return v[lx];
      |                         ^
secret.cpp:42:28: error: 'suff' was not declared in this scope; did you mean 'suf'?
   42 |     return ask(pref[x][l], suff[x][r]);
      |                            ^~~~
      |                            suf