#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(129);
vector<ll> nums(129);
ll n;
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,128) nums[i] = 1;
FOR(i,0,N) nums[i] = A[i];
sussy(0,128);
}
int Query(int L, int R){
ll lo = 0;
ll hi = 128;
while (lo<hi){
ll mid = (lo+hi)/2;
if (hi>n){
hi = mid;
continue;
}
if (L<=mid && mid<=R){
cout << mid << endl;
ll size = sus[mid].size()/2;
return Secret(sus[mid][size+(R-mid)], sus[mid][size - (mid - L)]);
}
if (mid<=L && mid<=R){
lo = mid;
}
if (mid >= L && mid >= R){
hi = mid;
}
}
}
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:84:1: warning: control reaches end of non-void function [-Wreturn-type]
84 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
20043 ms |
2396 KB |
Time limit exceeded |
2 |
Runtime error |
133 ms |
4768 KB |
Execution killed with signal 6 |
3 |
Execution timed out |
20062 ms |
2300 KB |
Time limit exceeded |
4 |
Incorrect |
451 ms |
4276 KB |
Do not print anything to standard output |
5 |
Execution timed out |
20074 ms |
4244 KB |
Time limit exceeded |
6 |
Execution timed out |
20047 ms |
4172 KB |
Time limit exceeded |
7 |
Incorrect |
431 ms |
4300 KB |
Do not print anything to standard output |
8 |
Incorrect |
433 ms |
4300 KB |
Do not print anything to standard output |
9 |
Incorrect |
435 ms |
4204 KB |
Do not print anything to standard output |
10 |
Runtime error |
458 ms |
8476 KB |
Execution killed with signal 6 |