Submission #661511

#TimeUsernameProblemLanguageResultExecution timeMemory
661511rxlfd314Secret (JOI14_secret)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; constexpr int mxN = 1005; int N, A[mxN], pref[mxN][mxN]; void precompute(int l, int r) { if (l == r) return; int mid = l + r >> 1; pref[mid][mid] = A[mid]; pref[mid+1][mid+1] = A[mid+1]; for (int i = mid - 1; i >= l; i--) { pref[mid][i] = Secret(pref[mid][i+1], A[i]); } for (int i = mid + 2; i <= r; i++) { pref[mid+1][i] = Secret(pref[mid+1][i], A[i]); } precompute(l, mid); precompute(mid + 1, r); } void Init(int n, int* a) { N = n; for (int i = 0; i < N; i++) { A[i] = a[i]; } precompute(0, N - 1); } void Query(int l, int r) { int lo = 0, hi = N - 1; while (lo < hi) { int mid = lo + hi >> 1; if (l <= mid && r > mid) { return Secret(pref[mid][l], pref[mid+1][r]); } if (r == mid) { return pref[mid][l]; } if (mid < l) { lo = mid + 1; } else { hi = mid; } } }

Compilation message (stderr)

secret.cpp: In function 'void precompute(int, int)':
secret.cpp:8:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    8 |  int mid = l + r >> 1;
      |            ~~^~~
secret.cpp: At global scope:
secret.cpp:27:6: error: ambiguating new declaration of 'void Query(int, int)'
   27 | void Query(int l, int r) {
      |      ^~~~~
In file included from secret.cpp:2:
secret.h:5:5: note: old declaration 'int Query(int, int)'
    5 | int Query(int L, int R);
      |     ^~~~~
secret.cpp: In function 'void Query(int, int)':
secret.cpp:30:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   30 |   int mid = lo + hi >> 1;
      |             ~~~^~~~
secret.cpp:32:17: error: return-statement with a value, in function returning 'void' [-fpermissive]
   32 |    return Secret(pref[mid][l], pref[mid+1][r]);
      |           ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
secret.cpp:35:22: error: return-statement with a value, in function returning 'void' [-fpermissive]
   35 |    return pref[mid][l];
      |           ~~~~~~~~~~~^