F - Set of Strings CodeForces - 544A (分割string)

F - Set of Strings

题目大意:

拆分成n个以不同首字母开头的字符串

#include<iostream>
#include<vector>
#include <string>
using namespace  std;
bool vis[35]={0};
int main()
{
	vector<int >q;
int n,sum=0;
string s;
cin>>n>>s;
for(int i=0;i<s.size();i++)
if(!vis[s[i]-'a'])
vis[s[i]-'a']=1,sum++,q.push_back(i);
if(sum<n)
cout<<"NO"<<endl;
else
{
	cout<<"YES"<<endl;
	for(int j=0;j<n;j++)
	{
		int k;
		if(j!=n-1)
		{
		for( k=q[j];k<q[j+1];k++)
		cout<<s[k];
		cout<<endl;
		}
		else 
		{
		for( k=q[j];k<s.size();k++)
		cout<<s[k];
		cout<<endl;
		}
	}
}
return 0;
}

 

### 关于 Codeforces 平台上的 KMP 算法练习题目 对于希望在 Codeforces 上找到有关 KMP (Knuth-Morris-Pratt) 字符串匹配算法的练习题目的选手来说,可以关注几个特定标签下的问题。通常这些题目会被标记为 "strings" 或者更具体地标记为 "string suffix structures"[^1]。 为了帮助更好地理解如何查找适合的练习题目,在此提供一段 Python 代码用于模拟访问 API 获取带有指定标签的问题列表: ```python import requests def fetch_problems(tag, platform="codeforces"): url = f"https://{platform}.com/api/problemset.problems?tags={tag}" response = requests.get(url) if response.status_code != 200: raise Exception(f"Failed to retrieve data from {platform}") json_data = response.json() problem_list = [] for index, item in enumerate(json_data['result']['problems']): name = item["name"] rating = item.get('rating', 'N/A') contest_id = item["contestId"] index = item["index"] problem_info = { "Name": name, "Rating": rating, "Link": f"{platform}.com/contest/{contest_id}/problem/{index}" } problem_list.append(problem_info) return problem_list[:5] # Example usage with the tag related to string processing or specifically KMP pattern matching. kmp_related_tag = "strings" fetched_problems = fetch_problems(kmp_related_tag) for prob in fetched_problems: print(prob) ``` 这段脚本会调用 Codeforces 的公开 API 来获取前五个与字符串处理相关的编程挑战链接,并打印出来供参考。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值