# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
866281 |
2023-10-25T18:13:12 Z |
Tudy006 |
Secret (JOI14_secret) |
C++14 |
|
389 ms |
8280 KB |
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
const int NMAX = 1000;
int answer[NMAX][NMAX];
int N;
//static int secret_count;
//
//int Secret(int X, int Y) {
// ++secret_count;
// if (!(0 <= X && X <= MAX_VALUE)) {
// fprintf(stderr, "Wrong Answer [1]\n");
// exit(0);
// }
// if (!(0 <= Y && Y <= MAX_VALUE)) {
// fprintf(stderr, "Wrong Answer [1]\n");
// exit(0);
// }
// return (X + 2 * (Y / 2) < MAX_VALUE) ? (X + 2 * (Y / 2)) : MAX_VALUE;
//}
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 == 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 |
1 |
Correct |
121 ms |
6740 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
111 ms |
6740 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
108 ms |
6724 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
386 ms |
8280 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
389 ms |
8272 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
389 ms |
8280 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
379 ms |
8260 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
389 ms |
8280 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
384 ms |
8280 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
388 ms |
8276 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |