# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
570960 |
2022-05-31T18:23:05 Z |
beaconmc |
Secret (JOI14_secret) |
C++14 |
|
478 ms |
4448 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
#define double long double
#include "secret.h"
using namespace std;
vector<vector<ll>> sus(1025);
vector<ll> nums(1025);
ll n;
// int Secret(ll a, ll b){
// return a+floor(b/2)*2;
// }
void sussy(ll a, ll b){
if (b-a > 2){
ll mid = (a+b)/2;
vector<ll> left;
vector<ll> right;
left.push_back(nums[mid-1]);
FORNEG(i, mid-2, a-1){
left.push_back(Secret(nums[i], left[left.size()-1]));
}
right.push_back(nums[mid]);
FOR(i,mid+1, b){
right.push_back(Secret(right[right.size()-1], nums[i]));
}
reverse(left.begin(), left.end());
for (auto&i : left){
sus[mid].push_back(i);
}
for (auto&i : right){
sus[mid].push_back(i);
}
sussy(a, mid);
sussy(mid, b);
}
}
void Init(int N, int A[]) {
n = N;
FOR(i,0,1025) nums[i] = 1;
FOR(i,0,N) nums[i] = A[i];
sussy(0,1024);
}
int Query(int L, int R){
if (R == L+1){
return Secret(nums[L], nums[R]);
}
if (L==R){
return nums[L];
}
ll lo = 0;
ll hi = 1024;
while (lo<hi){
ll mid = (lo+hi)/2;
if (L<=mid && mid<=R){
ll size = sus[mid].size()/2;
return Secret(sus[mid][size - (mid - L)], sus[mid][size+(R-mid)]);
}
if (mid<=L && mid<=R){
lo = mid;
}
if (mid >= L && mid >= R){
hi = mid;
}
}
}
// int main(){
// int sussy[8] = {1,4,7,2,5,8,3,6};
// Init(8, sussy);
// cout << Query(0,3) << endl;
// cout << Query(1,7) << endl;
// cout << Query(5,5) << endl;
// cout << Query(2,4) << endl;
// }
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:91:1: warning: control reaches end of non-void function [-Wreturn-type]
91 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
121 ms |
2384 KB |
Wrong Answer: Query(264, 271) - expected : 675707686, actual : 406865628. |
2 |
Incorrect |
121 ms |
2444 KB |
Wrong Answer: Query(236, 238) - expected : 173116186, actual : 416517106. |
3 |
Incorrect |
138 ms |
2512 KB |
Wrong Answer: Query(128, 153) - expected : 959658850, actual : 219466354. |
4 |
Incorrect |
451 ms |
4336 KB |
Wrong Answer: Query(384, 458) - expected : 896057572, actual : 118505579. |
5 |
Incorrect |
448 ms |
4388 KB |
Wrong Answer: Query(192, 207) - expected : 988576012, actual : 513550414. |
6 |
Incorrect |
478 ms |
4448 KB |
Wrong Answer: Query(888, 892) - expected : 825894562, actual : 137078433. |
7 |
Partially correct |
469 ms |
4440 KB |
Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1 |
8 |
Partially correct |
453 ms |
4324 KB |
Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1 |
9 |
Partially correct |
463 ms |
4396 KB |
Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1 |
10 |
Partially correct |
471 ms |
4304 KB |
Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1 |