题目链接:uva 1459 - Flowers Placement
暴力,在暴力的基础上用二分图匹配剪枝,如果当前位置放k,导致后面的位置不能匹配,即可回溯。
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn = 205;
int N, M, K, cnt, L[maxn], vis[maxn][maxn], ans[maxn];
bool T[maxn], used[maxn];
vector<int> G[maxn];
bool match (int u, int e) {
if (u <= e) return false;
for (int i = 0; i < G[u].size(); i++) {
int v = G[u][i];
if (!T[v]) {
T[v] = true;
if (!L[v] || match(L