思路:
设fi,j表示从1到i,n到j,回文合法的最小边数,然后直接双端bfs
c o d e code code
#include<iostream>
#include<cstdio>
#include<map>
#include<queue>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MAXN = 1e3 + 10;
ll n, m, tot, head[MAXN];
struct node {
ll to, next;
char s;
}b[MAXN * 2];
struct abc {
ll x, y;
string s;
}a[MAXN * 2];
int v[MAXN][MAXN];
bool cmp(abc x, abc y) {
if(x.x != y.x) return x.x