/**
* author: milos
* created: 26.12.2020 00:20:30
**/
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
vector<double> a;
/*int Secret(int X, int Y) {
return (X + 2 * (Y / 2) < MAX_VALUE) ? (X + 2 * (Y / 2)) : MAX_VALUE;
}*/
vector<pair<int, pair<vector<double>, vector<double>>>> ans;
int Query(int l, int r) {
for (auto c : ans) {
if (c.first >= l && c.first <= r) {
if (r == c.first) {
int j = c.first - l;
return c.second.first[j];
}
int j = c.first - l, z = r - c.first - 1;
return Secret(c.second.first[j], c.second.second[z]);
}
}
return 0;
}
void Solve(int l, int r) {
if (l > r) {
return;
}
int mid = (l + r) / 2;
vector<double> pref, suf;
double x = a[l];
pref.push_back(x);
for (int i = l + 1; i <= mid; i++) {
x = Secret(x, a[i]);
pref.push_back(x);
}
if (mid + 1 < (int) a.size()) {
x = a[mid + 1];
suf.push_back(x);
for (int i = mid + 2; i <= r; i++) {
x = Secret(x, a[i]);
suf.push_back(x);
}
}
ans.push_back({mid, {pref, suf}});
Solve(l, mid - 1);
Solve(mid + 1, r);
}
void Init(int N, int* A) {
for (int i = 0; i < N; i++) {
a.push_back((double) A[i]);
}
Solve(0, N - 1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
131 ms |
2540 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 571566486. |
2 |
Incorrect |
132 ms |
2540 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 745021832. |
3 |
Incorrect |
140 ms |
2668 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 411136036. |
4 |
Incorrect |
490 ms |
4588 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 372932671. |
5 |
Incorrect |
491 ms |
4388 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 714131476. |
6 |
Incorrect |
495 ms |
4588 KB |
Wrong Answer: Query(915, 915) - expected : 282904741, actual : 579799611. |
7 |
Incorrect |
497 ms |
4648 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 7995480. |
8 |
Incorrect |
495 ms |
4460 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 699777344. |
9 |
Incorrect |
510 ms |
4460 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 143144014. |
10 |
Incorrect |
495 ms |
4460 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 538405961. |