# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
729934 |
2023-04-24T22:23:01 Z |
jampm |
Secret (JOI14_secret) |
C++17 |
|
0 ms |
0 KB |
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
int const Mxn = 1e3 + 1;
int const LOGN = 13;
int ST[LOGN][Mxn];
int A[Mxn];
int n;
void Secret(int x, int y) {return x + y;}
void build(int L = 0, int R = n, int depth = 0) {
if (L + 1 == R) {
ST[depth][L] = A[L]; return;
}
int Mid = (L + R)>>1;
for (int i = Mid; i < R; i++) {
ST[depth][i] = (i == Mid) ? A[i] : Secret(ST[depth][i - 1], A[i]);
}
for (int i = Mid - 1; i >= L; i--) {
ST[depth][i] = (i == Mid - 1) ? A[i] : Secret(ST[depth][i + 1], A[i]);
}
build(L, Mid, depth + 1), build(Mid, R, depth + 1);
}
int query(int l, int r, int L = 0, int R = n, int depth = 0) {
if (L + 1 == R) return A[L];
int Mid = (L + R)>>1;
if (l <= Mid && Mid <= r) return Secret(ST[depth][l], ST[depth][r]);
if (r < Mid) return query(l, r, L, Mid, depth + 1);
else return query(l, r, Mid, R, depth + 1);
}
void Init(int N, int a[]) {
for (int i = 0; i < N; i++) A[i] = a[i];
n = N; build();
}
int Query(int L, int R) {
return query(L, R + 1);
}
Compilation message
secret.cpp:13:6: error: ambiguating new declaration of 'void Secret(int, int)'
13 | void Secret(int x, int y) {return x + y;}
| ^~~~~~
In file included from secret.cpp:1:
secret.h:7:5: note: old declaration 'int Secret(int, int)'
7 | int Secret(int X, int Y);
| ^~~~~~
secret.cpp: In function 'void Secret(int, int)':
secret.cpp:13:37: error: return-statement with a value, in function returning 'void' [-fpermissive]
13 | void Secret(int x, int y) {return x + y;}
| ~~^~~