Submission #837087

# Submission time Handle Problem Language Result Execution time Memory
837087 2023-08-24T21:57:49 Z MODDI Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
Compilation error
0 ms 0 KB
struct table{
    int n,logn;
    vector<vector<pii>> arr;
    vector<int> loglen;
    
    void init(int n_){
        n=1;
        logn=1;
        while(n<n_){
            n*=2;
            logn++;
        }
        loglen.resize(n+3);
        n=n_;
        int j=0;
        for(int i=1;i<n+3;i++){
            loglen[i]=j;
            if(i+1>(1<<(j+1))) j++;
        }
        
        arr.resize(logn);
        
        for(int i=0;i<logn;i++){
            arr[i].assign(n+1,mp(INF,-1));
        }
    }
    
    void set(vector<pii> &v){
        for(int j=0;j<n+1;j++){
            if(j<(int)v.size()) arr[0][j]=v[j];
        }
    }
    
    void set(int j, pii x){
        arr[0][j]=x;
    }
    
    void built(){
        for(int i=1;i<logn;i++){
            for(int j=0;j<n+1;j++){
                pii vl=arr[i-1][j],vr;
                if(j+(1<<(i-1))>=n+1) vr=mp(INF,-1);
                else vr=arr[i-1][j+(1<<(i-1))];
                arr[i][j]=min(vl,vr);
            }
        }
    }
    
    pii query(int l,int r){
        if(l>=r) return mp(INF,-1);
        pii vl=arr[loglen[r-l]][l],vr=arr[loglen[r-l]][r-(1<<loglen[r-l])];
        return min(vl,vr);
    }
};

Compilation message

sortbooks.cpp:3:5: error: 'vector' does not name a type
    3 |     vector<vector<pii>> arr;
      |     ^~~~~~
sortbooks.cpp:4:5: error: 'vector' does not name a type
    4 |     vector<int> loglen;
      |     ^~~~~~
sortbooks.cpp:28:14: error: 'vector' has not been declared
   28 |     void set(vector<pii> &v){
      |              ^~~~~~
sortbooks.cpp:28:20: error: expected ',' or '...' before '<' token
   28 |     void set(vector<pii> &v){
      |                    ^
sortbooks.cpp:34:21: error: 'pii' has not been declared
   34 |     void set(int j, pii x){
      |                     ^~~
sortbooks.cpp:49:5: error: 'pii' does not name a type
   49 |     pii query(int l,int r){
      |     ^~~
sortbooks.cpp: In member function 'void table::init(int)':
sortbooks.cpp:13:9: error: 'loglen' was not declared in this scope; did you mean 'logn'?
   13 |         loglen.resize(n+3);
      |         ^~~~~~
      |         logn
sortbooks.cpp:21:9: error: 'arr' was not declared in this scope
   21 |         arr.resize(logn);
      |         ^~~
sortbooks.cpp:24:34: error: 'INF' was not declared in this scope
   24 |             arr[i].assign(n+1,mp(INF,-1));
      |                                  ^~~
sortbooks.cpp:24:31: error: 'mp' was not declared in this scope
   24 |             arr[i].assign(n+1,mp(INF,-1));
      |                               ^~
sortbooks.cpp: In member function 'void table::set(int)':
sortbooks.cpp:30:23: error: 'v' was not declared in this scope
   30 |             if(j<(int)v.size()) arr[0][j]=v[j];
      |                       ^
sortbooks.cpp:30:33: error: 'arr' was not declared in this scope
   30 |             if(j<(int)v.size()) arr[0][j]=v[j];
      |                                 ^~~
sortbooks.cpp: In member function 'void table::set(int, int)':
sortbooks.cpp:35:9: error: 'arr' was not declared in this scope
   35 |         arr[0][j]=x;
      |         ^~~
sortbooks.cpp: In member function 'void table::built()':
sortbooks.cpp:41:17: error: 'pii' was not declared in this scope
   41 |                 pii vl=arr[i-1][j],vr;
      |                 ^~~
sortbooks.cpp:42:39: error: 'vr' was not declared in this scope
   42 |                 if(j+(1<<(i-1))>=n+1) vr=mp(INF,-1);
      |                                       ^~
sortbooks.cpp:42:45: error: 'INF' was not declared in this scope
   42 |                 if(j+(1<<(i-1))>=n+1) vr=mp(INF,-1);
      |                                             ^~~
sortbooks.cpp:42:42: error: 'mp' was not declared in this scope
   42 |                 if(j+(1<<(i-1))>=n+1) vr=mp(INF,-1);
      |                                          ^~
sortbooks.cpp:43:22: error: 'vr' was not declared in this scope
   43 |                 else vr=arr[i-1][j+(1<<(i-1))];
      |                      ^~
sortbooks.cpp:43:25: error: 'arr' was not declared in this scope
   43 |                 else vr=arr[i-1][j+(1<<(i-1))];
      |                         ^~~
sortbooks.cpp:44:17: error: 'arr' was not declared in this scope
   44 |                 arr[i][j]=min(vl,vr);
      |                 ^~~
sortbooks.cpp:44:31: error: 'vl' was not declared in this scope
   44 |                 arr[i][j]=min(vl,vr);
      |                               ^~
sortbooks.cpp:44:34: error: 'vr' was not declared in this scope
   44 |                 arr[i][j]=min(vl,vr);
      |                                  ^~
sortbooks.cpp:44:27: error: 'min' was not declared in this scope
   44 |                 arr[i][j]=min(vl,vr);
      |                           ^~~