Submission #152942

# Submission time Handle Problem Language Result Execution time Memory
152942 2019-09-10T15:52:58 Z Ruxandra985 popa (BOI18_popa) C++14
0 / 100
13 ms 248 KB
#include <cstdio>
#include "popa.h"
 
/// daca iese asa sunt zeita si intuitia mea este aur:)
int solve (int n , int *l , int *r){ /// return root
    int i,lant,root;
    int bgn[1010] , ed[1010] , tt[1010] , fii[1010];
    for (i=1;i<=n;i++){
        tt[i] = l[i] = r[i] = -1; /// reset all
    }
    /// separam in lanturi
    lant = 1;
    bgn[1] = ed[1] = 1;
    for (i=2;i<=n;i++){ /// n - 1
        if (query(bgn[lant] , i , i , i)){ /// i apartine lantului curent
            ed[lant]++;
            tt[i-1] = i;
        }
        else { /// incepem alt lant
            lant++;
            bgn[lant] = ed[lant] = i;
        }
    }
    /// mai bine obtin l si r din tt
    /// cum reusesc eu sa conectez aceste lanturi
    /// uniunile dintre lanturi se fac clar la nivelul lui ed
    /// pentru ca au indici consecutivi in s
    root = ed[1];
    for (i=2;i<=lant;i++){ /// ce fac cu lantul asta
        /// daca pot sa il unesc pe ed[i-1] cu ed[i]
        if (query(ed[i-1] , ed[i] , ed[i-1],ed[i-1])){
            tt[ed[i]] = ed[i-1]; /// unesti intervalele astea
        }
        else { /// daca nu pot cu aia , il fac pe ed[i] radacina
            tt[root] = ed[i];
            root = ed[i];
            ed[i]--;
        }
    }
 
    for (i=1;i<=n;i++){
        if (tt[i]!=-1){
            if (l[tt[i]]==-1)
                l[tt[i]] = i-1;
            else r[tt[i]] = i-1;
        }
    }
 
 
    return root-1;
}

Compilation message

popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:7:43: warning: unused variable 'fii' [-Wunused-variable]
     int bgn[1010] , ed[1010] , tt[1010] , fii[1010];
                                           ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 248 KB invalid argument
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 248 KB invalid argument
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 248 KB invalid argument
2 Halted 0 ms 0 KB -