#include<bits/stdc++.h> #define int long long #define x first #define y second #define MAXN 0x3f3f3f3f3f3f3f3f #define MINN -0x3f3f3f3f3f3f3f3f #define Trubiacy ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); usingnamespace std;
首先看到这道题,第一反应就是 DFS 跑连通块,但是经验告诉我 div2 应该不会在 B 题这样出,且我想不到跑完 DFS 之后怎么做,所以还是犹豫了比较长的一段时间。
后来官方发了新的 Announcement :
“The given grid contains at most one region” is the constraint on the input, not the comment on the picture from the statement. (”给出的网格最多包含一个连通区域“ 是对输入的限制,而不是对图片的说明。)
这个时候我才注意到原题中有这个对输入的限制,这个时候我们根据样例可以得出,若网格有如下结构( o 的位置为空),则 o 的位置可以放置障碍。
#include<bits/stdc++.h> #define int long long #define x first #define y second #define MAXN 0x3f3f3f3f3f3f3f3f #define MINN -0x3f3f3f3f3f3f3f3f #define Trubiacy ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); usingnamespace std;
#include<bits/stdc++.h> #define int long long #define x first #define y second #define MAXN 0x3f3f3f3f3f3f3f3f #define MINN -0x3f3f3f3f3f3f3f3f #define Trubiacy ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); usingnamespace std;
#include<bits/stdc++.h> #define int long long #define x first #define y second #define MAXN 0x3f3f3f3f3f3f3f3f #define MINN -0x3f3f3f3f3f3f3f3f #define Trubiacy ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); usingnamespace std;