Submission #233496

#TimeUsernameProblemLanguageResultExecution timeMemory
233496Dan13llljwsSecret (JOI14_secret)C++11
100 / 100
529 ms8524 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; int n, g[1005][1005]; void build(int l, int r){ if (r - l < 2) return; int mid = l + r >> 1; for (int i = mid - 1; i >= l; i--) g[i][mid] = Secret(g[i][i], g[i + 1][mid]); for (int i = mid + 2; i <= r; i++) g[mid + 1][i] = Secret(g[mid + 1][i - 1], g[i][i]); build(l, mid - 1), build(mid + 2, r); } void Init(int N, int A[]){ memset(g, -1, sizeof g); n = N; for (int i = 0; i < n; i++) g[i][i] = A[i]; build(0, n - 1); } int Query(int L, int R){ if (g[L][R] != -1) return g[L][R]; if (L + 1 == R) return Secret(g[L][L], g[R][R]); for (int i = L; i < R; i++) if (g[L][i] != -1 && g[i + 1][R] != -1) return Secret(g[L][i], g[i + 1][R]); }

Compilation message (stderr)

secret.cpp: In function 'void build(int, int)':
secret.cpp:7:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid = l + r >> 1;
            ~~^~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:25:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...