#define pii pair <int, int>
#define mp make_pair
#define x first
#define y second
queue <pii> q;
q.push (mp (n + 1, m + 1));
while (!q.empty ()) {
pii p = q.front ();
q.pop ();
// Q[p.x][p.y] = 2;
if (p.x + 1 <= n + 1 && Q[p.x + 1][p.y] == 0) {
Q[p.x + 1][p.y] = 2; // <1>
q.push (mp (p.x + 1, p.y));
}
if (p.x - 1 >= n - h + 1 && Q[p.x - 1][p.y] == 0) {
Q[p.x - 1][p.y] = 2; // <2>
q.push (mp (p.x - 1, p.y));
}
if (p.y + 1 <= m + 1 && Q[p.x][p.y + 1] == 0) {
Q[p.x][p.y + 1] = 2; // <3>
q.push (mp (p.x, p.y + 1));
}
if (p.y - 1 >= 0 && Q[p.x][p.y - 1] == 0) {
Q[p.x][p.y - 1] = 2; // <4>
q.push (mp (p.x, p.y - 1));
}
}
在这一段代码中,我要是把后面标注 <1> <2> <3> <4> 的代码删掉,还原回注释掉的那个代码,就会从 AC 178ms 到 TLE 80pts(时间限制 1000ms)。
这个是为什么呢?为什么换一种写法就 T 了?