BZOJ2738 矩阵乘法

全局二分的经典题。 最初试图用持久化线段树和分块,然后欢快地tle+mle了。看到jason_yu和mhy过了,只能说自己的常数优化还不过关啊。 第一次写这种二分。就是把所有东西扔进来快速排序,顺便考虑每个询问应该被扔到哪边。然后加树状数组来统计就好了。 代码巨丑。 #include <cstdio> #include <cctype> #include <cstring> #include <algorithm> using namespace std; struct query { int x1, y1, x2, y2, k, n; }; int _d_; #define readInt(_x_) { \ int& _s_ = _x_; \ while (!isdigit(_d_ = getchar())); \ _s_ = 0; \ while ((_s_ = _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar())); \ } const int maxn = 509; const int maxq = 310009; int n, m, t, maxa, a[maxn][maxn], b[maxn][maxn], ttm;...

December 26, 2014 · 3 min · laekov