Submission #957981

#TimeUsernameProblemLanguageResultExecution timeMemory
957981wkspSecret (JOI14_secret)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "secret.h" using namespace std; // int Secret(int X, int Y){ // int a; // cin >> a; // return a; // } const int n_max = 1024; const int log = 12; int tab[log][n_max]; // int tabr[log][n_max]; map<pair<int, int>, int> result_in_past; int check(int a, int b){ if(result_in_past.find({a, b}) != result_in_past.end()){ return result_in_past[{a, b}]; }else{ int x = Secret(a, b); result_in_past[{a, b}] = x; return x; } } void init_tree(int n, int lvl = 10, int l = 0, int r = n_max - 1){ if(l > n){ return; } if(lvl == 0){ return; } int mid = (l+r)/2; init_tree(n, lvl - 1, l, mid); init_tree(n, lvl - 1, mid + 1, r); if(mid >= n){ return; } tab[lvl][mid] = tab[0][mid]; for(int i = mid - 1; i >= l; i--){ tab[lvl][i] = check(tab[0][i], tab[lvl][i+1]); } tab[lvl][mid + 1] = tab[0][mid+1]; for(int i = mid + 2; i <= min(n, r); i++){ tab[lvl][i] = check(tab[lvl][i-1], tab[0][i]); } } int find_in_tree(int a, int b, int lvl = 10, int l = 0, int r = n_max - 1){ int mid = (l+r)/2; if(r <= mid){ return find_in_tree(a, b, lvl - 1, l, mid); } if(l > mid){ return find_in_tree(a, b, lvl - 1, mid + 1, r); } return check(tab[lvl][l], tab[lvl][r]); } void Init(int N, int A[]){ for(int i = 0; i < N; i++){ tab[0][i] = A[i]; } init_tree(N); } int Query(int L, int R){ if(L == R){ return tab[0][L]; } return find_in_tree(L, R); } // int main(){ // return 0; // }

Compilation message (stderr)

secret.cpp:11:11: error: 'const int log' redeclared as different kind of entity
   11 | const int log = 12;
      |           ^~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from secret.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:104:1: note: previous declaration 'double log(double)'
  104 | __MATHCALL_VEC (log,, (_Mdouble_ __x));
      | ^~~~~~~~~~~~~~
secret.cpp:12:19: error: could not convert 'std::log' from '<unresolved overloaded function type>' to 'long unsigned int'
   12 | int tab[log][n_max];
      |                   ^
secret.cpp:12:5: error: size of array 'tab' has non-integral type '<unresolved overloaded function type>'
   12 | int tab[log][n_max];
      |     ^~~