Submission #639152

# Submission time Handle Problem Language Result Execution time Memory
639152 2022-09-08T18:08:33 Z phoenix Secret (JOI14_secret) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "secret.h"

using namespace std;

const int N = 1000;
const int logN = 10;

// int opCount = 0;
// int Secret(int x, int y) {
//     opCount++;
//     return (x + y) % (100000000);
// }

int lef[ N ][ logN ], rig[ N ][ logN ];
void build(int l, int r, int lev, int a[]) {
    if(r - l <= 1) {
        lef[ l ][ lev ] = a[ l ];
        rig[ r ][ lev ] = a[ r ];
        return;
    }
    int m = (l + r) / 2;
    for(int i = m + 1;i <= r;i++) {
        if(i == m + 1) rig[ i ][ lev ] = a[ i ];
        else rig[ i ][ lev ] = Secret(rig[i - 1][ lev ], a[ i ]);
    }
    for(int i = m;i >= l;i--) {
        if(i == m) lef[ i ][ lev ] = a[ i ];
        else lef[ i ][ lev ] = Secret(lef[i + 1][ lev ], a[ i ]);
    }

    build(l, m, lev + 1, a);
    build(m + 1, r, lev + 1, a);
}

int query(int ql, int qr, int l, int r, int lev) {
    if(l == r) 
        return lef[ l ][ lev ];
    int m = (l + r) / 2;
    if(ql <= m && m < qr) {
        return Secret(lef[ ql ][ lev ], rig[ qr ][ lev ]); 
    }
    if(qr <= m)
        return query(ql, qr, l, m, lev + 1);
    return query(ql, qr, m + 1, r, lev + 1);
}
int n;
void Init(int nn, int a[]) {
    n = nn;
    build(0, n - 1, 0, a);
}

int Query(int l, int r) {
    if(l == r) return 
    return query(l, r, 0, n - 1, 0);
}


// int main() {
//     int n;
//     cin >> n;
//     vector<int> a(n);
//     init(n, a);
//     cout << opCount;
// }

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:55:5: error: expected primary-expression before 'return'
   55 |     return query(l, r, 0, n - 1, 0);
      |     ^~~~~~
secret.cpp:54:22: error: expected ';' before 'return'
   54 |     if(l == r) return
      |                      ^
      |                      ;
   55 |     return query(l, r, 0, n - 1, 0);
      |     ~~~~~~