Submission #837759

#TimeUsernameProblemLanguageResultExecution timeMemory
837759danitroSecret (JOI14_secret)C++14
100 / 100
412 ms4492 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; #define MAX 1024 int table[25][MAX], n; void build(int n, int a[], int l, int r, int level) { if(l > r)return; if(l == r) { table[level][l] = a[l]; return; } int mid = (l + r) / 2; table[level][mid + 1] = a[mid + 1]; for(int i = mid + 2; i <= r; i++)table[level][i] = Secret(table[level][i - 1], a[i]); table[level][mid] = a[mid]; for(int i = mid - 1; i >= l; i--)table[level][i] = Secret(a[i], table[level][i + 1]); build(n, a, l, mid, level + 1); build(n, a, mid + 1, r, level + 1); return; } void Init(int N, int A[]) { n = N; build(N, A, 0, n - 1, 0); } int Query(int L, int R) { int l = 0, r = n - 1, mid, lev = 0, opt; while(l <= L && R <= r && r - l > 0) { mid = (l + r) / 2; if(L > mid)l = mid + 1; else r = mid; opt = lev++; } if(L == R)return table[opt][L]; return Secret(table[opt][L], table[opt][R]); }

Compilation message (stderr)

secret.cpp: In function 'int Query(int, int)':
secret.cpp:49:15: warning: 'opt' may be used uninitialized in this function [-Wmaybe-uninitialized]
   49 |  return Secret(table[opt][L], table[opt][R]);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...