CodeForcesGym 100524J Jingles of a String
Jingles of a String
This problem will be judged on CodeForcesGym. Original ID: 100524J
64-bit integer IO format: %I64d Java class name: (Any)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = ;
int st[maxn][];
char str[maxn];
int query(int L,int R) {
int lg = - __builtin_clz(R - L + );
return st[L][lg]|st[R - (<<lg) + ][lg];
}
unordered_map<int,int>ump;
int main() {
#define NAME "jingles"
freopen(NAME".in","r",stdin);
freopen(NAME".out","w",stdout);
int kase;
scanf("%d",&kase);
while(kase--) {
scanf("%s",str);
int len = strlen(str);
for(int i = ; i < len; ++i)
st[i][] = <<(str[i] - 'a');
for(int j = ; (<<j) <= len; ++j) {
for(int i = ; i + (<<j) <= len; ++i)
st[i][j] = st[i][j-]|st[i+(<<(j-))][j-];
}
ump.clear();
for(int i = ; i < len; ++i) {
int x = query(i,len - );
ump[x] = max(ump[x],len - i);
int cnt = __builtin_popcount(x);
for(int j = ; j < cnt; ++j) {
int low = i,high = len-,ret;
while(low <= high) {
int mid = (low + high)>>;
int y = __builtin_popcount(query(i,mid));
if(y <= j) {
low = mid + ;
ret = mid;
} else high = mid - ;
}
ump[query(i,ret)] = max(ump[query(i,ret)],ret - i + );
}
}
LL ans = ;
for(auto &it:ump)
ans += __builtin_popcount(it.first)*(LL)it.second;
printf("%d %I64d\n",ump.size(),ans);
}
return ;
}
CodeForcesGym 100524J Jingles of a String的更多相关文章
- CodeForcesGym 100735H Words from cubes
Words from cubes Time Limit: Unknown ms Memory Limit: 65536KB This problem will be judged on CodeFor ...
- CodeForcesGym 100735G LCS Revised
LCS Revised Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on CodeForcesGym. O ...
- CodeForcesGym 100641B A Cure for the Common Code
A Cure for the Common Code Time Limit: 3000ms Memory Limit: 262144KB This problem will be judged on ...
- CodeForcesGym 100548G The Problem to Slow Down You
The Problem to Slow Down You Time Limit: 20000ms Memory Limit: 524288KB This problem will be judged ...
- CodeForcesGym 100676G Training Camp
G. Training Camp Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on CodeForces ...
- 透过WinDBG的视角看String
摘要 : 最近在博客园里面看到有人在讨论 C# String的一些特性. 大部分情况下是从CODING的角度来讨论String. 本人觉得非常好奇, 在运行时态, String是如何与这些特性联系上的 ...
- JavaScript String对象
本编主要介绍String 字符串对象. 目录 1. 介绍:阐述 String 对象的说明以及定义方式. 2. 实例属性:介绍 String 对象的实例属性: length. 3. 实例方法:介绍 St ...
- ElasticSearch 5学习(9)——映射和分析(string类型废弃)
在ElasticSearch中,存入文档的内容类似于传统数据每个字段一样,都会有一个指定的属性,为了能够把日期字段处理成日期,把数字字段处理成数字,把字符串字段处理成字符串值,Elasticsearc ...
- [C#] string 与 String,大 S 与小 S 之间没有什么不可言说的秘密
string 与 String,大 S 与小 S 之间没有什么不可言说的秘密 目录 小写 string 与大写 String 声明与初始化 string string 的不可变性 正则 string ...
随机推荐
- linux知识目录
linux 知识目录 linux 前台后台程序切换命令总结 shell脚本从入门到精通 Ubuntu下如何用命令运行deb安装包 <linux就该这么学>学习笔记
- ACM数论-求组合数
我们利用这个公式求阶乘和逆元求阶: #include<cstdio> const int N = 200000 + 5; const int MOD = (int)1e9 + 7; int ...
- log4js日志配置问题
http://blog.csdn.net/cdnight/article/details/50857268 在做项目中,我们的node日志采用的是log4js框架,使用文件方式存储,但在后面的需求中增 ...
- String的用法——获取功能
package cn.itcast_04; /* String类获取功能 int length():获取字符的长度 char charAt(int index):获取指定索引位置的字符 int ind ...
- android环境搭建环境 cordova run android gradle wrapper报错
cordova run android命令报错 Error: Could not find an installed version of Gradle either in Android Studi ...
- 掌握Spark机器学习库-07-线性回归算法概述
1)简介 自变量,因变量,线性关系,相关系数,一元线性关系,多元线性关系(平面,超平面) 2)使用线性回归算法的前提 3)应用例子 沸点与气压 浮力与表面积
- R in action读书笔记(15)第十一章 中级绘图 之二 折线图 相关图 马赛克图
第十一章 中级绘图 本节用到的函数有: plot legend corrgram mosaic 11.2折线图 如果将散点图上的点从左往右连接起来,那么就会得到一个折线图. 创建散点图和折线图: &g ...
- zookeeper启动
Zookeeper启动总结1.实际项目用的是Linux,问题不大,本地开发学习用Windows,问题多多.2.Zookeeper3.5.1-alpha,和本地JDK1.7,有冲突,无法正常启动.3.Z ...
- MySQL性能优化之max_connections配置
MySQL的最大连接数,增加该值增加mysqld 要求的文件描述符的数量.如果服务器的并发连接请求量比较大,建议调高此值,以增加并行连接数量,当然这建立在机器能支撑的情况下,因为如果连接数越多,介于M ...
- cp - 复制文件和目录
总览 cp [选项] 文件路径 cp [选项] 文件...目录 POSIX 选项: [-fipRr] GNU 参数(最短形式): [-abdfilprsuvxPR] [-S SUFFIX] [-V { ...