Submission #866279

#TimeUsernameProblemLanguageResultExecution timeMemory
866279Tudy006Secret (JOI14_secret)C++14
0 / 100
391 ms8600 KiB
#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]; if ( r - l <= 1 ) return; 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 timeMemoryGrader output
Fetching results...