# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
217217 |
2020-03-29T08:52:59 Z |
tselmegkh |
Secret (JOI14_secret) |
C++14 |
|
593 ms |
8440 KB |
#include<bits/stdc++.h>
#include "secret.h"
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 1e5 + 5, inf = 1e9;
#define pb push_back
#define mp make_pair
#define ll long long
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define sz(x) (int)x.size()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int ans[1005][1005];
void solve(int l, int r, int a[]){
if(l == r){
return;
}
int mid = (l + r) / 2;
for(int i = mid - 1; i >= l; i--){
ans[i][mid] = Secret(a[i], ans[i + 1][mid]);
}
for(int i = mid + 2; i <= r; i++){
ans[mid + 1][i] = Secret(ans[mid + 1][i - 1], a[i]);
}
solve(l, mid, a);
solve(mid + 1, r, a);
}
void Init(int n, int a[]){
memset(ans, -1, sizeof ans);
for(int i = 0; i < n; i++)ans[i][i] = a[i];
solve(0, n - 1, a);
}
int Query(int ql, int qr){
if(ans[ql][qr] != -1)return ans[ql][qr];
for(int i = ql; i < qr; i++){
if(ans[ql][i] != -1 && ans[i + 1][qr] != -1){
return Secret(ans[ql][i], ans[i + 1][qr]);
}
}
}
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
164 ms |
6392 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
160 ms |
6396 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
155 ms |
6392 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
527 ms |
8236 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
539 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
524 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
593 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
571 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
535 ms |
8440 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
584 ms |
8312 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |