首页 > 其他分享 >Codeforces Round #833 (Div. 2)-B

Codeforces Round #833 (Div. 2)-B

时间:2022-11-17 16:35:12浏览次数:63  
标签:833 ch int ll Codeforces long Div include define

B

题目链接:https://codeforces.com/contest/1748/problem/B

 What is the maximum possible length a diverse string?

100! 10个数字每个出现10次

暴力n*102

下见代码

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mem(x,y) memset(x,y,sizeof(x))
//#define int long long

inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}

using namespace std;
const int maxm=1e5+5,inf=0x3f3f3f3f;
int n;
string ss;

void solve(){
	cin>>n>>ss;
	int ans=0,maxlen,types;
	vector<int> cnt(100,0);
	for(int i=0;i<n;++i){
		maxlen=types=0;
		cnt.assign(100,0);
		for(int j=i;j<i+101&&j<n;++j){
			if(cnt[ss[j]]==0){
				++types;
			}
			++cnt[ss[j]];
			maxlen=max(maxlen,cnt[ss[j]]);
			if(types>=maxlen) ++ans;
		}
	}
	cout<<ans<<endl; 
	return ;
}

signed main(){
//	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int _=1;
	cin>>_;
	while(_--){
		solve();
	}
	return 0;
}

  

标签:833,ch,int,ll,Codeforces,long,Div,include,define
From: https://www.cnblogs.com/Qiansui/p/16899884.html

相关文章

  • B. Diverse Substrings
    题目链接:Problem-B-Codeforces输入71727741010501100639999652345618789987887987998798输出1210121015106题目大意就是给出T个用例给出一个长度为n,只包含'0'......
  • Codeforces Gym 100958 E Cellular Automaton (Makoto rng_58 Soejima contest) 题解
    题目链接其实"序列中1的数量有限"是一个非常重要的条件。这意味着我们可以找到序列中的第一个1和最后一个1。考虑这样一件事情:初始时我们把一个长度为\(2^{2w+1}\)的"滑......
  • vue3点击其他元素隐藏固定DIV
    vue3点击其他元素隐藏固定DIV显示的内容<divv-if="hSearch"ref="iscity"><div><inputclass="h-9w-full"placeholder="内容搜索..."/></div></div>元......
  • Codeforces Round #833 (Div. 2) D
    D.ConstructOR转化题意a|x=k1db|x=k2d我们考虑k1k2同样就只用让x包含a|b对于a|b的每一位我们用d的最后一位来填补然后在线的要是a|b这里有我们的x没有显然要让......
  • CodeForces - 212E IT Restaurants
    题意:给一棵树的结点染色,每个结点可以染红色、蓝色或不染色。相邻两个结点必须染同一种颜色,或者一个染色一个不染色。求整棵树染色结点最多,且在整棵树至少有一个结点染红色,......
  • From CodeForces Catlogs
    2022/11/1https://codeforces.com/blog/entry/106346On"isthisgreedyorDP",forcingandrubberbandsreadingotherpeople'sthoughtprocessesTheylookatth......
  • Codeforces Round #180 (Div. 2) 解题报告
    ​​题目链接​​A.​​SnowFootprints​​​​A-SnowFootprints​​Thestartingpositioncanbeanywherewithafootprint.Thefootprintscanbecategorized......
  • 2022 年杭电多校第六场 Multiply 2 Divide 2
    2022年杭电多校第六场Multiply2Divide2题意:BXY的序列\(a\)长度为\(n\)\((1\leqn\leq10^5,1\leqa_i\leq10^5)\)对于每个操作,他选择一个数字\(a_i(1\leqi\leqn......
  • codeforces补题计划
    11.15CodeforcesRound#833(Div.2)知识点:D:高位和对低位无影响E:笛卡尔树上dp补题传送门......
  • Codeforces Round #833 (Div. 2)补题
    CodeforcesRound#833(Div.2)D.ConstructOR知识点:高位和对低位无影响一开始以为和广州的M一样,是数位dp,后来发现只要找到一个就行果然无论什么时候都要看清题目......