#include <cstdio>
#include "popa.h"
/// cum adc runtime:(
int solve (int n , int *l , int *r){ /// return root
int i,lant,root,bgn,ed,eda;
int tt[1010];
for (i=0;i<n;i++){
tt[i] = l[i] = r[i] = -1; /// reset all
}
/// separam in lanturi
lant = 1;
bgn = ed = 0;
eda = -1; /// cel de care poti lipi
for (i=1;i<n;i++){ /// n - 1
if (query(bgn , i , i , i)){ /// i apartine lantului curent
ed = i;
tt[i-1] = i;
}
else { /// incepem alt lant
if ( lant != 1 ){ /// vedem cum il unim
if (query(eda , ed , eda , eda)){
tt[ed] = eda; /// unesti intervalele astea
}
else { /// daca nu pot cu aia , il fac pe ed[i] radacina
tt[root] = ed;
root = ed;
ed--;
}
}
else root = ed;
lant++;
eda = ed;
bgn = ed = i;
}
}
if ( lant != 1 ){ /// vedem cum il unim
if (query(eda , ed , eda , eda)){
tt[ed] = eda; /// unesti intervalele astea
}
else { /// daca nu pot cu aia , il fac pe ed[i] radacina
tt[root] = ed;
root = ed;
ed--;
}
}
else root = ed;
/// uniunile dintre lanturi se fac clar la nivelul lui ed
/// pentru ca au indici consecutivi in s
for (i=0;i<n;i++){
if (tt[i]!=-1){
if (l[tt[i]]==-1)
l[tt[i]] = i;
else r[tt[i]] = i;
}
}
return root;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
20 ms |
372 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
17 ms |
436 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |