# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
866280 | Tudy006 | Secret (JOI14_secret) | C++14 | 416 ms | 8528 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"
using namespace std;
const int NMAX = 1000;
int answer[NMAX][NMAX];
int N;
void divide_init( int l, int r, int* v ) {
if ( l == r ) {
answer[l][r] = v[l];
return;
}
int mij = ( l + r ) / 2;
answer[mij][mij] = v[mij];
answer[mij + 1][mij + 1] = v[mij + 1];
for ( int i = mij - 1; i >= l; i -- ) {
answer[i][mij] = Secret( v[i], answer[i + 1][mij] );
}
for ( int i = mij + 2; i <= r; i ++ ) {
answer[mij + 1][i] = Secret( answer[mij + 1][i - 1], v[i] );
}
divide_init( l, mij, v );
divide_init( mij + 1, r, v );
}
int divide_query( int st, int dr, int l, int r ) {
int mij = ( st + dr ) / 2;
if ( l <= mij && mij <= r ) {
if ( mij == l || mij == r ) return answer[l][r];
return Secret( answer[l][mij], answer[mij + 1][r] );
}
if ( mij < l ) return divide_query( mij + 1, dr, l, r );
return divide_query( st, mij, l, r );
}
void Init(int n, int v[] ) {
N = n;
divide_init( 0, n - 1, v );
}
int Query( int l, int r ) {
return divide_query( 0, N - 1, l, r );
}
//int main() {
//
// return 0;
//}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |