#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#include "grader.cpp"
#endif
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
Tran The Bao
CTL - Da Lat
Cay ngay cay dem nhung deo duoc cong nhan
*/
const int MAXN = 1000;
int n;
int d[MAXN][MAXN];
void build(int l, int r, int a[]) {
if (l == r) {
d[l][l] = a[l];
return;
}
int mid = l + (r - l) / 2;
build(l, mid, a);
build(mid + 1, r, a);
FOR(i, mid + 1, r) d[l][i] = Secret(d[l][i - 1], d[mid + 1][i]);
FOR(i, l, mid) d[i][r] = Secret(d[i][mid], d[mid + 1][r]);
}
void Init(int N, int A[]) {
n = N;
build(0, N - 1, A);
}
int Query(int L, int R) {
int l = 0, r = n - 1;
WHILE(1) {
int mid = l + (r - l) / 2;
if (L <= mid && mid <= R) {
int a = d[L][mid], b = (mid + 1 > R? -1 : d[mid + 1][R]);
if (b != -1) return Secret(a, b);
return a;
}
if (mid < L) l = mid + 1;
else r = mid;
}
return 0;
}
Compilation message
secret.cpp: In function 'void build(int, int, int*)':
secret.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
| ^
secret.cpp:49:5: note: in expansion of macro 'FOR'
49 | FOR(i, mid + 1, r) d[l][i] = Secret(d[l][i - 1], d[mid + 1][i]);
| ^~~
secret.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
26 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
| ^
secret.cpp:50:5: note: in expansion of macro 'FOR'
50 | FOR(i, l, mid) d[i][r] = Secret(d[i][mid], d[mid + 1][r]);
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
113 ms |
4436 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 34826383. |
2 |
Incorrect |
117 ms |
4468 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 529760361. |
3 |
Incorrect |
123 ms |
4464 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 815841618. |
4 |
Incorrect |
440 ms |
8172 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 848822508. |
5 |
Incorrect |
446 ms |
8200 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 578846794. |
6 |
Incorrect |
428 ms |
8168 KB |
Wrong Answer: Query(185, 194) - expected : 834216008, actual : 142763928. |
7 |
Incorrect |
448 ms |
8188 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 251143258. |
8 |
Incorrect |
423 ms |
8376 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 636838208. |
9 |
Incorrect |
444 ms |
8276 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 939797869. |
10 |
Incorrect |
433 ms |
8264 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 537683718. |