# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
930627 |
2024-02-20T08:27:10 Z |
oblantis |
Secret (JOI14_secret) |
C++17 |
|
464 ms |
5368 KB |
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include "secret.h"
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 1e6 + 1;
//int secret_count;
map<pii, int> sh;
//int Secret(int X, int Y) {
//++secret_count;
//return (X + 2 * (Y / 2));
//}
void go(int l, int r){
if(l + 2 >= r)return;
int mid = l + (r - l) / 2;
for(int i = mid - 2; i >= l; i--){
sh[{i, mid - 1}] = Secret(sh[{i, i}], sh[{i + 1, mid - 1}]);
}
for(int i = mid + 1; i <= r; i++){
sh[{mid, i}] = Secret(sh[{mid, i - 1}], sh[{i, i}]);
}
go(l, mid);
go(mid, r);
}
void Init(int n, int a[]) {
for(int i = 0; i < n; i++){
sh[{i, i}] = a[i];
}
go(0, n);
}
int Query(int l, int r) {
if(sh.find({l, r}) != sh.end())return sh[{l, r}];
for(int j = l; j < r; j++){
if(sh.find({l, j}) != sh.end() && sh.find({j + 1, r}) != sh.end()){
return Secret(sh[{l, j}], sh[{j + 1, r}]);
}
}
return 0;
}
//int main(){
//int n;
//cin >> n;
//int a[n];
//for(int i = 0; i < n; i++){
//cin >> a[i];
//}
//Init(n, a);
//int q;
//cin >> q;
//while(q--){
//int l, r;
//cin >> l >> r;
//cout << Query(l, r) << '\n';
//}
//return 0;
//}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
129 ms |
2896 KB |
Output is correct - number of calls to Secret by Init = 3833, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
129 ms |
2980 KB |
Output is correct - number of calls to Secret by Init = 3841, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
129 ms |
2900 KB |
Output is correct - number of calls to Secret by Init = 3851, maximum number of calls to Secret by Query = 1 |
4 |
Partially correct |
409 ms |
4856 KB |
Output isn't correct - number of calls to Secret by Init = 8480, maximum number of calls to Secret by Query = 1 |
5 |
Partially correct |
436 ms |
5120 KB |
Output isn't correct - number of calls to Secret by Init = 8489, maximum number of calls to Secret by Query = 1 |
6 |
Partially correct |
365 ms |
4932 KB |
Output isn't correct - number of calls to Secret by Init = 8489, maximum number of calls to Secret by Query = 1 |
7 |
Partially correct |
457 ms |
5020 KB |
Output isn't correct - number of calls to Secret by Init = 8489, maximum number of calls to Secret by Query = 1 |
8 |
Partially correct |
462 ms |
5368 KB |
Output isn't correct - number of calls to Secret by Init = 8489, maximum number of calls to Secret by Query = 1 |
9 |
Partially correct |
464 ms |
5020 KB |
Output isn't correct - number of calls to Secret by Init = 8489, maximum number of calls to Secret by Query = 1 |
10 |
Partially correct |
460 ms |
5100 KB |
Output isn't correct - number of calls to Secret by Init = 8489, maximum number of calls to Secret by Query = 1 |