# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
954530 |
2024-03-28T06:12:51 Z |
IBory |
Secret (JOI14_secret) |
C++17 |
|
378 ms |
4772 KB |
#include "secret.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
using namespace std;
const int MAX = 1004;
map<pii, int> D;
int N, S[MAX];
void DnC1(int L, int R) {
if (L >= R) return;
int mid = (L + R) >> 1;
int pv = -1;
for (int i = mid - 1; i >= L; --i) {
int n = -1;
if (pv == -1) n = Secret(S[i], S[mid]);
else n = Secret(S[i], pv);
pv = D[{i, mid}] = n;
}
pv = -1;
for (int i = mid + 2; i <= R; ++i) {
int n = -1;
if (pv == -1) n = Secret(S[mid + 1], S[i]);
else n = Secret(pv, S[i]);
pv = D[{mid + 1, i}] = n;
}
DnC1(L, mid);
DnC1(mid + 1, R);
}
void Init(int _N, int A[]) {
N = _N;
for (int i = 0; i < N; ++i) S[i] = A[i];
DnC1(0, N - 1);
for (int i = 0; i < N; ++i) D[{i, i}] = A[i];
}
int DnC2(int L, int R, int s, int e) {
if (L >= R) return -1;
int mid = (L + R) >> 1;
if (s <= mid && mid < e) {
int a = D[{s, mid}], b = D[{mid + 1, e}];
return Secret(a, b);
}
if (e <= mid) return DnC2(L, mid, s, e);
else return DnC2(mid + 1, R, s, e);
}
int Query(int L, int R) {
return DnC2(0, N - 1, L, R);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
99 ms |
2728 KB |
Wrong Answer: Query(56, 56) - expected : 677274107, actual : -1. |
2 |
Incorrect |
99 ms |
2724 KB |
Wrong Answer: Query(389, 389) - expected : 472506730, actual : -1. |
3 |
Incorrect |
99 ms |
2724 KB |
Wrong Answer: Query(18, 18) - expected : 238214183, actual : -1. |
4 |
Incorrect |
369 ms |
4688 KB |
Wrong Answer: Query(788, 788) - expected : 937598145, actual : -1. |
5 |
Incorrect |
369 ms |
4684 KB |
Wrong Answer: Query(957, 957) - expected : 115761809, actual : -1. |
6 |
Incorrect |
373 ms |
4688 KB |
Wrong Answer: Query(915, 915) - expected : 282904741, actual : -1. |
7 |
Correct |
378 ms |
4772 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
378 ms |
4692 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
377 ms |
4688 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
376 ms |
4688 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |