# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
957990 |
2024-04-04T15:31:57 Z |
wksp |
Secret (JOI14_secret) |
C++14 |
|
382 ms |
4928 KB |
#include<bits/stdc++.h>
#include "secret.h"
using namespace std;
// int Secret(int X, int Y){
// int a;
// cin >> a;
// return a;
// }
const int n_max = 1024;
const int logn = 12;
int tab[logn][n_max];
// int tabr[log][n_max];
map<pair<int, int>, int> result_in_past;
int check(int a, int b){
if(result_in_past.find({a, b}) != result_in_past.end()){
return result_in_past[{a, b}];
}else{
int x = Secret(a, b);
result_in_past[{a, b}] = x;
return x;
}
}
void init_tree(int n, int lvl = 10, int l = 0, int r = n_max - 1){
if(l > n){
return;
}
if(lvl == 0){
return;
}
int mid = (l+r)/2;
init_tree(n, lvl - 1, l, mid);
init_tree(n, lvl - 1, mid + 1, r);
if(mid >= n){
return;
}
tab[lvl][mid] = tab[0][mid];
for(int i = mid - 1; i >= l; i--){
tab[lvl][i] = check(tab[0][i], tab[lvl][i+1]);
}
tab[lvl][mid + 1] = tab[0][mid+1];
for(int i = mid + 2; i <= min(n, r); i++){
tab[lvl][i] = check(tab[lvl][i-1], tab[0][i]);
}
}
int find_in_tree(int a, int b, int lvl = 10, int l = 0, int r = n_max - 1){
int mid = (l+r)/2;
if(r <= mid){
return find_in_tree(a, b, lvl - 1, l, mid);
}
if(l > mid){
return find_in_tree(a, b, lvl - 1, mid + 1, r);
}
return lvl;
//return check(tab[lvl][l], tab[lvl][r]);
}
void Init(int N, int A[]){
for(int i = 0; i < N; i++){
tab[0][i] = A[i];
}
init_tree(N);
}
int Query(int L, int R){
if(L == R){
return tab[0][L];
}
return find_in_tree(L, R);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
109 ms |
2900 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 10. |
2 |
Incorrect |
114 ms |
2980 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 10. |
3 |
Incorrect |
99 ms |
2984 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 10. |
4 |
Incorrect |
382 ms |
4772 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 10. |
5 |
Incorrect |
373 ms |
4772 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 10. |
6 |
Incorrect |
372 ms |
4776 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 10. |
7 |
Incorrect |
373 ms |
4680 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 10. |
8 |
Incorrect |
376 ms |
4708 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 10. |
9 |
Incorrect |
369 ms |
4776 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 10. |
10 |
Incorrect |
380 ms |
4928 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 10. |