제출 #866280

#제출 시각아이디문제언어결과실행 시간메모리
866280Tudy006비밀 (JOI14_secret)C++14
0 / 100
416 ms8528 KiB
#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 timeMemoryGrader output
Fetching results...