# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
837759 |
2023-08-25T15:56:28 Z |
danitro |
Secret (JOI14_secret) |
C++14 |
|
412 ms |
4492 KB |
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
#define MAX 1024
int table[25][MAX], n;
void build(int n, int a[], int l, int r, int level)
{
if(l > r)return;
if(l == r)
{
table[level][l] = a[l];
return;
}
int mid = (l + r) / 2;
table[level][mid + 1] = a[mid + 1];
for(int i = mid + 2; i <= r; i++)table[level][i] = Secret(table[level][i - 1], a[i]);
table[level][mid] = a[mid];
for(int i = mid - 1; i >= l; i--)table[level][i] = Secret(a[i], table[level][i + 1]);
build(n, a, l, mid, level + 1);
build(n, a, mid + 1, r, level + 1);
return;
}
void Init(int N, int A[])
{
n = N;
build(N, A, 0, n - 1, 0);
}
int Query(int L, int R)
{
int l = 0, r = n - 1, mid, lev = 0, opt;
while(l <= L && R <= r && r - l > 0)
{
mid = (l + r) / 2;
if(L > mid)l = mid + 1;
else r = mid;
opt = lev++;
}
if(L == R)return table[opt][L];
return Secret(table[opt][L], table[opt][R]);
}
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:49:15: warning: 'opt' may be used uninitialized in this function [-Wmaybe-uninitialized]
49 | return Secret(table[opt][L], table[opt][R]);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
2492 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
111 ms |
2492 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
110 ms |
2444 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
380 ms |
4388 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
391 ms |
4328 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
385 ms |
4404 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
386 ms |
4492 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
412 ms |
4396 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
390 ms |
4344 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
406 ms |
4408 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |