题意:给定一个序列,问你它有多少上连续的子串,能够重排后是一个回文串。

析:直接暴力,n 比较小不会超时。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
//#include <tr1/unordered_map>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;
//using namespace std :: tr1; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e3 + 5;
const LL mod = 10000000000007;
const int N = 1e6 + 5;
const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
inline LL gcd(LL a, LL b){ return b == 0 ? a : gcd(b, a%b); }
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
char s[maxn];
int cnt[30]; int main(){
int T; cin >> T;
for(int kase = 1; kase <= T; ++kase){
scanf("%s", s);
int ans = 0;
n = strlen(s); for(int i = 0; i < n; ++i){
memset(cnt, 0, sizeof cnt);
int cnt1 = 0;
for(int j = i; j < n; ++j){
++cnt[s[j]-'a'];
if(cnt[s[j]-'a'] & 1) ++cnt1;
else --cnt1;
if(cnt1 < 2) ++ans;
}
} printf("Case %d: %d\n", kase, ans);
}
return 0;
}

UVa 12718 Dromicpalin Substrings (暴力)的更多相关文章

  1. UVA.12716 GCD XOR (暴力枚举 数论GCD)

    UVA.12716 GCD XOR (暴力枚举 数论GCD) 题意分析 题意比较简单,求[1,n]范围内的整数队a,b(a<=b)的个数,使得 gcd(a,b) = a XOR b. 前置技能 ...

  2. UVA.10305 Maximum Product (暴力)

    UVA.10305 Maximum Product (暴力) 题意分析 直接枚举起点和重点,然后算出来存到数组里面,sort然后取最大值即可. 代码总览 #include <iostream&g ...

  3. uva 725 Division(暴力模拟)

    Division 紫书入门级别的暴力,可我还是写了好长时间 = = [题目链接]uva 725 [题目类型]化简暴力 &题解: 首先要看懂题意,他的意思也就是0~9都只出现一遍,在这2个5位数 ...

  4. UVA - 1602 Lattice Animals (暴力+同构判定)

    题目链接 题意:求能放进w*h的网格中的不同的n连通块个数(通过平移/旋转/翻转后相同的算同一种),1<=n<=10,1<=w,h<=n. 刘汝佳的题真是一道比一道让人自闭.. ...

  5. UVA 253 Cube painting(暴力打表)

    Cube painting Problem Description: We have a machine for painting cubes. It is supplied with three d ...

  6. Uva 10167 - Birthday Cake 暴力枚举 随机

      Problem G. Birthday Cake Background Lucy and Lily are twins. Today is their birthday. Mother buys ...

  7. uva 12009 - Avaricious Maryanna(暴力)

    option=com_onlinejudge&Itemid=8&category=516&page=show_problem&problem=3160" ta ...

  8. hdu1238 Substrings (暴力)

    http://acm.hdu.edu.cn/showproblem.php?pid=1238 Substrings Time Limit : 2000/1000ms (Java/Other)   Me ...

  9. UVa 818Cutting Chains (暴力dfs+位运算+二进制法)

    题意:有 n 个圆环,其中有一些已经扣在一起了,现在要打开尽量少的环,使所有的环可以组成一条链. 析:刚开始看的时候,确实是不会啊....现在有点思路,但是还是差一点,方法也不够好,最后还是参考了网上 ...

随机推荐

  1. 【HDOJ6301】Distinct Values(贪心,set)

    题意:给定一个n个数的数列与m个区间,要求每个区间内的数字互不相同,求使得数列字典序最小的方案 n<=1e5 思路: #include<cstdio> #include<vec ...

  2. BZOJ1573: [Usaco2009 Open]牛绣花cowemb

    求半径d<=50000的圆(不含边界)内n<=50000条直线有多少交点,给直线的解析式. 一开始就想,如果能求出直线交点与原点距离<d的条件,那么从中不重复地筛选即可.然而两个kx ...

  3. PHP的资源类型

    PHP的资源类型 php的资源类型 常见的有:打开文件.数据库连接.图形画布等. 常用操作:创建.使用.释放. 以文件操作为示例: //文件路径 $file_url = './data.txt'; / ...

  4. Rem 字体设置学习一

    JS方法动态计算根元素的字体大小: [淘宝首页:m.taobao.com] (function (doc, win) { var docEl = doc.documentElement, resize ...

  5. poj2553 有向图缩点,强连通分量。

    //求这样的sink点:它能达到的点,那个点必能达到他,即(G)={v∈V|任意w∈V:(v→w)推出(w→v)} //我法:tarjan缩点后,遍历点,如果该点到达的点不在同一个强连通中,该点排除, ...

  6. Linux进程IPC浅析[进程间通信SystemV共享内存]

    Linux进程IPC浅析[进程间通信SystemV共享内存] 共享内存概念,概述 共享内存的相关函数 共享内存概念,概述: 共享内存区域是被多个进程共享的一部分物理内存 多个进程都可把该共享内存映射到 ...

  7. Android切图注意事项

    1.App Logo大小共五种: 48*48 72*72 96*96 144*144 192*192 2. App启动页所需尺寸: 320×480 480×800 720*1280 1080*1920 ...

  8. [NPM] npm check to update the dependencies

    To update the dependencies in the project, we can run: npx npm-check -u

  9. 新浪微博发送消息和授权机制原理(WeiboSDK)

    1.首先是在微博发送消息,对于刚開始做weibo发送消息的刚開始学习的人会有一个误区,那就是会觉得须要授权后才干够发送消息.事实上发送消息仅仅须要几行代码就能够实现了,很easy,不须要先授权再发送消 ...

  10. 3.将maven项目jar纳入maven仓库,Mave项目依赖另外一个Maven项目的案例

     1 若想让maven项目依赖另外一个maven项目.被依赖的项目要在maven仓库中有对应的jar包,所以要对依赖的项目运行mvninstall命令. 2 新建第二个项目模块HelloFrien ...