# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092374 | vjudge1 | Secret (JOI14_secret) | C++17 | 342 ms | 12236 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "secret.h"
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("popcnt")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using lld = long double;
using ii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<ii>;
using vpll = vector<pll>;
using vlld = vector<lld>;
// #define endl '\n'
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define gcd(a,b) __gcd(a,b)
#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fls cout.flush()
#define fore(i,l,r) for(auto i=l;i<r;i++)
#define fo(i,n) fore(i,0,n)
#define forex(i,r,l) for(auto i=r; i>=l;i--)
#define ffo(i,n) forex(i,n-1,0)
bool cmin(ll &a, ll b) { if(b<a){a=b;return 1;}return 0; }
bool cmax(ll &a, ll b) { if(b>a){a=b;return 1;}return 0; }
void valid(ll in) { cout<<((in)?"YES\n":"NO\n"); }
ll lcm(ll a, ll b) { return (a/gcd(a,b))*b; }
ll gauss(ll n) { return (n*(n+1))/2; }
const int N = 1001;
int n, a[N], pr[4*N][N], sf[4*N][N];
void build(int id, int l, int r) {
if (l == r) return;
int m = (l+r)/2;
pr[id][m+1] = a[m+1];
fore (i, m+2, r+1) pr[id][i] = Secret(pr[id][i-1], a[i]);
sf[id][m] = a[m];
forex (i, m-1, l) sf[id][i] = Secret(a[i], sf[id][i+1]);
build(id*2, l, m);
build(id*2+1, m+1, r);
}
void Init (int n, int A[]) {
::n = n;
fo (i, n) a[i] = A[i];
build(1, 0, n-1);
}
int Query(int i, int j) {
if (i == j) return a[i];
int l = 0, r = n-1, id = 1;
while (1) {
int m = (l+r)/2;
if (i<=m && j>m) return Secret(sf[id][i], pr[id][j]);
if (i<=m) r = m;
if (i>m) l = m+1;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |