#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debug_with_space(x) cerr << #x << " " << x << " "
#include "secret.h"
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <long double, pii> muchie;
const ll NMAX = 300001;
const ll INF = (1LL << 60);
const ll MOD = 998244353;
const ll BLOCK = 225;
const ll base = 31;
const ll nr_of_bits = 21;
int table[1001][1001], n;
void divide(int l, int r){
if(l == r || l > r)
return;
int mid = (l + r) / 2;
for(int i = mid - 1; i >= l; i--){
table[i][mid] = Secret(table[i][i], table[i + 1][mid]);
}
for(int i = mid + 2; i <= r; i++){
table[mid + 1][i] = Secret(table[mid + 1][i - 1], table[i][i]);
}
divide(l, mid);
divide(mid + 1, r);
}
void Init(int N, int A[]) {
n = N;
for(int i = 0; i < N; i++)
table[i][i] = A[i];
divide(0, N - 1);
}
int q(int st, int dr, int l, int r){
int mid = (st + dr) / 2;
if(st == dr)
return table[st][dr];
if(l <= mid && mid + 1 <= r){
return Secret(table[l][mid], table[mid + 1][r]);
}
if(r <= mid){
return q(st, mid, l, r);
}
if(l > mid){
return q(mid + 1, dr, l, r);
}
}
int Query(int L, int R) {
return q(0, n - 1, L, R);
}
Compilation message
secret.cpp: In function 'int q(int, int, int, int)':
secret.cpp:54:1: warning: control reaches end of non-void function [-Wreturn-type]
54 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
144 ms |
4360 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
142 ms |
4388 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
153 ms |
4384 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
505 ms |
8308 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
505 ms |
8076 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
520 ms |
8188 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
514 ms |
8264 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
516 ms |
8260 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
505 ms |
8084 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
518 ms |
8132 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |