【Codeforces 258D】 Count Good Substrings
【题目链接】
http://codeforces.com/contest/451/problem/D
【算法】
合并后的字符串一定是形如"ababa","babab",ab交替出现的字符串
那么,判断一段是否为回文,只需判断首尾字符是否相等即可
【代码】
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + ; int i;
long long ans1,ans2;
char s[MAXN];
long long sum[][]; int main()
{ scanf("%s",s+);
for (i = ; i <= strlen(s + ); i++)
{
sum[i%][s[i]-'a']++;
if (i % == )
{
ans1 += sum[][s[i]-'a'];
ans2 += sum[][s[i]-'a'];
} else
{
ans1 += sum[][s[i]-'a'];
ans2 += sum[][s[i]-'a'];
}
}
printf("%I64d %I64d\n",ans1,ans2); return ; }
【Codeforces 258D】 Count Good Substrings的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【POJ 2777】 Count Color(线段树区间更新与查询)
[POJ 2777] Count Color(线段树区间更新与查询) Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4094 ...
- 【codeforces 514C】Watto and Mechanism(字符串hash)
[题目链接]:http://codeforces.com/contest/514/problem/C [题意] 给你n个字符串; 然后给你m个询问;->m个字符串 对于每一个询问字符串 你需要在 ...
- 【codeforces 768E】Game of Stones
[题目链接]:http://codeforces.com/contest/768/problem/E [题意] NIM游戏的变种; 要求每一堆石头一次拿了x个之后,下一次就不能一次拿x个了; 问你结果 ...
- 【35.29%】【codeforces 557C】Arthur and Table
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【41.43%】【codeforces 560C】Gerald's Hexagon
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【25.64%】【codeforces 570E】Pig and Palindromes
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 742B】Arpa’s obvious problem and Mehrdad’s terrible solution
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【19.46%】【codeforces 551B】ZgukistringZ
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
随机推荐
- 【HTTP】如何正常关闭连接
参考:<HTTP权威指南> 所有HTTP客户端.服务器或者代理都可以任意时刻关闭一条TCP传输连接.但是服务器永远无法确定它关闭“空闲”连接的那一刻,在线路那一头的客户端有没有数据要发送. ...
- 自动换行 word-break:break-all和word-wrap:break-word
1.word-break:break-all;当内容(比如很长的一个单词)到每行的末端时,它会把单词截断显示一部分,下一行显示后一部分. 2.word-wrap:break-word;当内容(比如很长 ...
- UID卡、CUID卡、FUID卡的区别
UID卡(国外称GEN1) 所有区块可被重复读写 卡片ID可改且使用后门指令更改ID ID可被重复修改 响应后门指令(意味着可被使用后门指令检测是否为克隆卡的机器发现) CUID卡(国外称GEN2) ...
- (转)Redis研究(一)—简介
http://blog.csdn.net/wtyvhreal/article/details/41855327 Redis是一个开源的高性能键值对数据库.它通过提供多种键值数据类型来适应不同场景下的存 ...
- CryptoJS简单使用(request.js) 拦截器的使用
首先准备一份明文和秘钥: var plaintText = 'aaaaaaaaaaaaaaaa'; // 明文var keyStr = 'bbbbbbbbbbbbbbbb'; // 一般key为一个字 ...
- Tomcat 服务器中jsp页面乱码
<Connector port="80" protocol="HTTP/1.1" connectionTimeout=&quo ...
- matlab学习使用Button Group绘制不同的正弦曲线
创建buttongroup控件---即按钮组 再添加三个radiobutton 对其设置 buttongroup控件改Title为绘制不同正弦曲线 第一个radiobutton的string改为sin ...
- BZOJ 2959: 长跑 LCT_并查集_点双
真tm恶心...... Code: #include<bits/stdc++.h> #define maxn 1000000 using namespace std; void setIO ...
- esp32(M5STACK) ARDUINO开发环境搭建(ubuntu)
首先去官网下载arduino https://www.arduino.cc/en/main/software 由于国产链接下载慢的缘故,所以可以采用百度网盘的方式进行下载,具体下载方法 ...
- yum的方式搭建mysql
1.安装相应的软件yum install mysql : 安装mysql客户端 yum install mysql-server 安装服务端 yum install mysql-devel 安装相关的 ...