Submission #487242

#TimeUsernameProblemLanguageResultExecution timeMemory
487242MohamedAliSaidaneSecret (JOI14_secret)C++14
100 / 100
437 ms8676 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<ld,ld> pld; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pii> vpi; typedef vector<pll> vpl; typedef vector<pld> vpd; #define pb push_back #define popb pop_back #define all(v) (v).begin(),(v).end() #define ff first #define ss second const ll MOD = 1e9 + 7; const ll INF = 1e18; /////// SOLUTION \\\\\\\ const int MAX_N = 1111; int a[1111]; int n; int range[MAX_N][MAX_N]; void build(int l, int r) { if(r - l < 2) return ; int m = (l+r)/2; for(int i = m-1; i >=l; i--) { if(range[i][m] != -1) continue; range[i][m] = Secret(range[i][i],range[i+1][m]); } for(int i = m +2; i <=r; i ++) { if(range[m+1][i] != -1) continue; range[m+1][i] = Secret(range[m+1][i-1],range[i][i]); } build(l,m-1); build(m+1,r); } void Init(int N, int A[]) { n = N; for(int i= 0; i <n; i ++) a[i] = A[i]; for(int i = 0; i <n; i ++) for(int j= 0; j <n; j ++) range[i][j] = -1; for(int i= 0; i <n; i ++) range[i][i] = a[i]; build(0,n-1); } int Query(int l, int r) { if(range[l][r] != -1) return range[l][r]; for(int i = l; i <r; i++) { if(range[l][i] != -1 && range[i+1][r] != -1) return range[l][r]= Secret(range[l][i],range[i+1][r]); } } /*int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt; while(tt--) { solve(); } }*/

Compilation message (stderr)

secret.cpp:26:1: warning: multi-line comment [-Wcomment]
   26 | /////// SOLUTION \\\\\\\
      | ^
secret.cpp: In function 'int Query(int, int)':
secret.cpp:71:1: warning: control reaches end of non-void function [-Wreturn-type]
   71 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...