template<class T> int BSearch(T* v, int n, T& t){ int l = -1, u = n, m; while(l+1 != u) { m = (l + u) >> 1; if(v[m] < t) l = m; else u = m; } return (u >= n || v[u] != t) ? -1 : u;}