问题
https://vjudge.net/problem/UVA-10716
分析
贪心,一开始像成了迭代加深搜索,后来发现不行,复杂度太高了。
从两端向中心看,首先如果两端的字母相同,向中心移动,如果不同,就选择其中的一个作为端点,另一个移动,进行比较,哪种方式移动次数较少就选择哪一个。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int maxn=100+5;
int kase=0,cnt[26];
char s[maxn];
int main(void){
scanf("