# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
242405 |
2020-06-27T15:32:11 Z |
AM1648 |
Secret (JOI14_secret) |
C++17 |
|
507 ms |
4600 KB |
/* be name khoda */
// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
#include "secret.h"
using namespace std;
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif
typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;
#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))
#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;
#define XL (x << 1)
#define XR (XL | 1)
#define MD ((l + r) >> 1)
#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD
// -----------------------------------------------------------------------
const ll maxn = 1002;
const ll maxnlg = 10;
ll n, A[maxn];
ll pre[maxnlg][maxn];
void calc(ll h, ll l, ll r) {
if (r - l <= 2) return;
ll mid = (l + r) / 2;
pre[h][mid] = A[mid], pre[h][mid - 1] = A[mid - 1];
forifrom (i, mid + 1, r) pre[h][i] = Secret(pre[h][i - 1], A[i]);
forirto (i, mid - 1, l) pre[h][i] = Secret(pre[h][i + 1], A[i]);
calc(h + 1, l, mid);
calc(h + 1, mid, r);
}
ll find(ll L, ll R, ll h = 0, ll l = 0, ll r = n) {
if (h > 20) return -1;
ll mid = (l + r) / 2;
if (L >= mid) return find(L, R, h + 1, l, mid);
if (R <= mid) return find(L, R, h + 1, mid, r);
else return Secret(pre[h][L], pre[h][R - 1]);
}
void Init(ll N, ll I[]) {
n = N;
fori (i, n) A[i] = I[i];
calc(0, 0, n);
}
ll Query(ll l, ll r) {
++r;
if (r - l == 1) return A[l];
else if (r - l == 2) return Secret(A[l], A[l + 1]);
else return find(l, r);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
139 ms |
2428 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : -1. |
2 |
Incorrect |
137 ms |
2404 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
138 ms |
2424 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 162768982. |
4 |
Incorrect |
498 ms |
4344 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : -1. |
5 |
Incorrect |
503 ms |
4344 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : -1. |
6 |
Incorrect |
496 ms |
4304 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : -1. |
7 |
Incorrect |
501 ms |
4412 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873. |
8 |
Incorrect |
500 ms |
4344 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792. |
9 |
Incorrect |
507 ms |
4472 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577. |
10 |
Incorrect |
501 ms |
4600 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787. |