Submission #628187

# Submission time Handle Problem Language Result Execution time Memory
628187 2022-08-13T07:31:11 Z I_am_balancing Secret (JOI14_secret) C++17
Compilation error
0 ms 0 KB
#include "secret.h"
using ll = long long;
int val[12][1005], a[1005], n;

void precalc(ll l, ll r, ll la){
    ll m = (l+r)>>1;
    val[la][m] = a[m];
    if(l >= r)return;
    if(l<=m-1)val[la][m-1] = a[m-1];
    for(ll i = m+1;i<=r;i++)val[la][i]=Secret(val[la][i-1],a[i]);
    for(ll i = m-2;i>=l;i--)val[la][i]=Secret(val[la][i+1],a[i]);
    precalc(l,m-1,la+1);
    precalc(m+1,r,la+1);
}

void Init(int N, int A[]){
    for(ll i = 0;i<N;i++)a[i] = A[i];
    precalc(0,N-1,0);
    n = N;
}
int query(int L, int R, ll l = 0, ll r = n-1, ll la = 0){
    ll m = (l+r)>>1;
    printf("mid: %d\n",m);
    fflush(stdout);
    if(L <= m && m <= R){
        if(L!=m)
        return Secret(val[la][L],val[la][R]);
        return val[la][R];
    }
    if(m > L)return query(L,R,l,m,la+1);
    return query(L,R,m+1,r,la+1);
}

int Query(int L, int R){
    return query(L,R);
}

Compilation message

secret.cpp: In function 'int query(int, int, ll, ll, ll)':
secret.cpp:23:5: error: 'printf' was not declared in this scope
   23 |     printf("mid: %d\n",m);
      |     ^~~~~~
secret.cpp:2:1: note: 'printf' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
    1 | #include "secret.h"
  +++ |+#include <cstdio>
    2 | using ll = long long;
secret.cpp:24:12: error: 'stdout' was not declared in this scope
   24 |     fflush(stdout);
      |            ^~~~~~
secret.cpp:24:12: note: 'stdout' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
secret.cpp:24:5: error: 'fflush' was not declared in this scope
   24 |     fflush(stdout);
      |     ^~~~~~