#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){
ans[l][r] = a[l];
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);
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]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
143 ms |
6392 KB |
Wrong Answer [1] |
2 |
Incorrect |
144 ms |
6368 KB |
Wrong Answer [1] |
3 |
Incorrect |
145 ms |
6392 KB |
Wrong Answer [1] |
4 |
Incorrect |
516 ms |
8312 KB |
Wrong Answer [1] |
5 |
Incorrect |
511 ms |
8288 KB |
Wrong Answer [1] |
6 |
Incorrect |
524 ms |
8312 KB |
Wrong Answer [1] |
7 |
Incorrect |
549 ms |
8224 KB |
Wrong Answer [1] |
8 |
Incorrect |
523 ms |
8312 KB |
Wrong Answer [1] |
9 |
Incorrect |
568 ms |
8312 KB |
Wrong Answer [1] |
10 |
Incorrect |
520 ms |
8288 KB |
Wrong Answer [1] |