Submission #523040

# Submission time Handle Problem Language Result Execution time Memory
523040 2022-02-06T19:11:08 Z Neacsu_Mihai Trampoline (info1cup20_trampoline) C++14
Compilation error
0 ms 0 KB
 
int cautareBinara(int x,int y)
{
    int st=1,dr=N,mij=0,ras=0;
    while (st<=dr)
    {
        mij=(st+dr)/2;
        if (s[mij].first>x) {dr=mij-1;}
        else if (s[mij].first<x) {st=mij+1;}
        else if (s[mij].second<y) {st=mij+1;}
        else {dr=mij-1; ras=mij;}
    }
    return ras;
}
/*
int cautareBinara(int x, int y){
 
        //Imi returneaza, din lista de trambuline verzi, numarul celei de pe linia x, cu lowerboundul ei = y
        //daca nu exista niciunul pe linia x, returneaza 0
 
 
    int lo = 0;
    int hi = N + 1;
    int ans = 0;
 
    while(hi - lo > 1){
        int mid = lo + (hi - lo) / 2;
 
        if(s[mid].first > x){
            hi = mid;
        }
        else if(s[mid].first < x){
            lo = mid;
        }
        else if(s[mid].second < y){
            lo = mid;
        }
        else {
            ans = mid;
            hi = mid;
        }
    }
 
    return ans;
}*/
/*
int stramos(int node, int nr){
    if(nr == 0){
        return YMAX + 1;
    }
 
    for(int i = 19; i >= 0; i--){
        if( (1 << i) <= nr ){
            node = t[i][node];
            nr -= (1 << i);
        }
    }
    ///daca node ajunge sa fie 0, inseamna ca nu exista al nr-lea stramos al lui node
    ///dar la mine trebuie sa existe ca sa zic 'Yes', ca altfel inseamna ca nu am destule trambuline pe drum
    ///adica inseamna ca nu am trambuline de la (xs, xf) destule
    ///si atunci vreau sa returnez ceva care sa ma faca sa afisez 'No', adica returnez un 'y' f mare, pentru ca eu urmeaza sa il compar cu yf
    if(node == 0){
        return YMAX + 1;
    }
 
    return s[node].second; ///returneaza 'y'-ul celui de-al 'nr'-ulea stramos al lui 'node'
}
*/
 
int stramos(int nod,int lvl)
{
    for (int i=19;i>=0;--i)
    {
        if ((1<<i)<=lvl)
        {
            nod=t[i][nod];
            lvl-=(1<<i);
        }
    }
    if (nod==0) return 2000000000;
    return s[nod].second;
}
 

Compilation message

trampoline.cpp: In function 'int cautareBinara(int, int)':
trampoline.cpp:4:17: error: 'N' was not declared in this scope
    4 |     int st=1,dr=N,mij=0,ras=0;
      |                 ^
trampoline.cpp:7:9: error: 'mij' was not declared in this scope
    7 |         mij=(st+dr)/2;
      |         ^~~
trampoline.cpp:8:13: error: 's' was not declared in this scope; did you mean 'st'?
    8 |         if (s[mij].first>x) {dr=mij-1;}
      |             ^
      |             st
trampoline.cpp:11:25: error: 'ras' was not declared in this scope
   11 |         else {dr=mij-1; ras=mij;}
      |                         ^~~
trampoline.cpp:13:12: error: 'ras' was not declared in this scope
   13 |     return ras;
      |            ^~~
trampoline.cpp: In function 'int stramos(int, int)':
trampoline.cpp:76:17: error: 't' was not declared in this scope
   76 |             nod=t[i][nod];
      |                 ^
trampoline.cpp:81:12: error: 's' was not declared in this scope
   81 |     return s[nod].second;
      |            ^