#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
int bollocks[1000][1000], divider[129], arr[1000], en;
void solve(int x, int y) {
int mid = (x + y) / 2;
bollocks[mid][mid] = arr[mid]; bollocks[mid + 1][mid + 1] = arr[mid + 1];
for (int i = mid - 1; i >= x; i--) {
bollocks[i][mid] = Secret(arr[i], bollocks[i + 1][mid]);
}
for (int i = mid + 2; i <= y; i++) {
bollocks[mid + 1][i] = Secret(bollocks[mid + 1][i - 1], arr[i]);
}
if (x < mid) {
solve(x, mid);
}
if (y > mid + 1) {
solve(mid + 1, y);
}
}
void Init(int n, int a[]) {
en = n;
for (int i=0;i<n;i++) {
arr[i] = a[i];
}
solve(0, n - 1);
}
int Query(int L, int R) {
if (L == R) {
return bollocks[L][R];
}
int top = en - 1, bottom = 0, mid;
while (true) {
mid = (top + bottom) / 2;
if (L > mid) {
bottom = mid;
} else if (R < mid) {
top = mid;
} else {
break;
}
}
int lol;
if (R == mid) {
return bollocks[L][R];
} else {
lol = Secret(bollocks[L][mid], bollocks[mid + 1][R]);
if (lol == 536870912) {
cout << 1/0;
}
return lol;
}
}
Compilation message
secret.cpp: In function 'int Query(int, int)':
secret.cpp:60:16: warning: division by zero [-Wdiv-by-zero]
60 | cout << 1/0;
| ~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
85 ms |
8784 KB |
Execution killed with signal 4 |
2 |
Correct |
90 ms |
4592 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
89 ms |
4432 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Runtime error |
323 ms |
16464 KB |
Execution killed with signal 4 |
5 |
Runtime error |
332 ms |
16624 KB |
Execution killed with signal 4 |
6 |
Incorrect |
303 ms |
8276 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 0. |
7 |
Correct |
322 ms |
8276 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
315 ms |
8248 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
323 ms |
8272 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
312 ms |
8356 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |