Skip to content

Commit

Permalink
博文内容里的代码加上raw标记
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-kan committed Feb 24, 2019
1 parent 045e890 commit d71f85a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions _posts/2019-02-24-CodeForces-641E.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ int main()
}
}
```
时间最优解当然是动态开点线段树啦,比上面的代码快了一倍(170ms:342ms),空间也小了一些(45300kB:52676kB)。
时间最优解当然是动态开点线段树啦,比上面的代码快了正好一倍(171ms:342ms),空间也小了一些(45344kB:52676kB)。

启示是,假如题目空间给的足够大的话,可以用建在map上的树状数组来偷懒代替线段树来维护区间和。
{% raw %}
```cpp
#include <bits/stdc++.h>
using namespace std;
Expand Down Expand Up @@ -101,7 +102,7 @@ struct SegmentTree
return ask(l, m, v[rt].lc) + ask(m + 1, r, v[rt].rc);
}
};
unordered_map<int, SegmentTree> mp;
map<int, SegmentTree> mp;
int n, a, t, x;
int main()
{
Expand All @@ -115,3 +116,4 @@ int main()
}
}
```
{% endraw %}

0 comments on commit d71f85a

Please sign in to comment.