Skip to content
Snippets Groups Projects
Commit 3f16da49 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Small improvements

parent 8e93f6cd
No related branches found
No related tags found
No related merge requests found
......@@ -3,12 +3,13 @@
/// Complexity (Time): O(log n)
/// Complexity (Space): O(1)
struct BinaryExponentiation {
/// Returns x^n in O(log n) time
/// @param x number
/// @param n exponent
template <typename T>
T fast_pow(T x, ll n) {
T ans = 1;
ll fast_pow(ll x, ll n) {
ll ans = 1;
while (n) {
if (n & 1)
......@@ -20,3 +21,4 @@ T fast_pow(T x, ll n) {
return ans;
}
};
......@@ -4,7 +4,6 @@
/// Complexity (Space): O(1)
struct TernarySearch {
const double EPS = 1e-6;
/// Unimodal function
double f(double x) {
......
......@@ -32,13 +32,11 @@ int query(int idx) {
return sum;
}
void update(int idx, int val) {
for (; idx <= MAX; idx += (idx & -idx))
tree[idx] += val;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
......
......@@ -48,7 +48,6 @@ int main() {
while (!Q.empty()) {
elem curr = Q.front(); Q.pop();
cont[curr.fi.fi][curr.fi.se][curr.se.fi] = 1;
if (mat[curr.fi.fi][curr.fi.se] == '*')
return cout << curr.se.se << ende, 0;
......@@ -63,14 +62,14 @@ int main() {
if (mat[x][y] >= 'A' && mat[x][y] <= 'G') {
if (msk & (1 << (mat[x][y] - 'A'))) {
//cont[x][y][msk] = 1;
cont[x][y][msk] = 1;
Q.push({{x, y}, {msk, curr.se.se + 1}});
}
} else {
if (mat[x][y] >= 'a' && mat[x][y] <= 'g')
msk |= (1 << (mat[x][y] - 'a'));
//cont[x][y][msk] = 1;
cont[x][y][msk] = 1;
Q.push({{x, y}, {msk, curr.se.se + 1}});
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment