湖南多校对抗赛3.28 D Simple String

<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">Problem D: Simple String</span>

Time Limit: 1 Sec  Memory Limit: 256 MB
Submit: 74  Solved: 35
[Submit][Status][Web Board]

Description

Welcome,this is the 2015 3th Multiple Universities Programming Contest ,Changsha ,Hunan Province. In order to let you feel fun, ACgege will give you a simple problem. But is that true? OK, let’s enjoy it.
There are three strings A , B and C. The length of the string A is 2*N, and the length of the string B and C is same to A. You can take N characters from A and take N characters from B. Can you set them to C ?

 

Input

There are several test cases.
Each test case contains three lines A,B,C. They only contain upper case letter.
0<N<100000
The input will finish with the end of file.

 

Output

For each the case, if you can get C, please print “YES”. If you cann’t get C, please print “NO”.

 

Sample Input

AABB
BBCC
AACC
AAAA
BBBB
AAAA

Sample Output

YES
NO

题意:有A,B,C三串字符串,取A,B串的各一半,问能不能组成C;

思路:分别记录A,B,C里面每个元素出现的个数,如果a[i] + b[i] < c[i],那么就直接输出NO;

用min_a记录a最少要拿出几个字母,用max_a记录a最多要拿出几个字母,如果len/2在min_a和max_a之间,就输出YES,否则输出NO。
代码如下:
#include<cstdio>
#include<cstring>
const int maxn=100005;
char A[maxn], B[maxn], C[maxn];
int a[maxn], b[maxn], c[maxn];
int main()
{
	while(scanf("%s%s%s", &A, &B, &C)!=EOF)
	{
		for(int i=0; i<26; i++)
		{
			a[i]=0, b[i]=0, c[i]=0;
		}
		int len=strlen(A);
		for(int i=0;  i<len; i++)
		{
			a[A[i]-'A']++;
		}
		for(int i=0;  i<len; i++)
		{
			b[B[i]-'A']++;
		}
		for(int i=0;  i<len; i++)
		{
			c[C[i]-'A']++;
		}
		int min_a=0, max_a=0;
		int flag=0;
		for(int i=0; i<26; i++)
		{
			if(a[i]+b[i]<c[i])
			{
				flag=1; 
				printf("NO\n");
				break;
			}
			else
			{
				if(c[i]>b[i])
				{
					min_a+=c[i]-b[i];
				}
				if(a[i]>c[i])
				{
					max_a+=c[i];
				}
				else max_a+=a[i];
			}
		}
		if(!flag)
		{
			int mid=len/2;
			if(mid>=min_a && mid<=max_a)
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
	}
	return 0;
}


【SCI一区复现】基于配电网韧性提升的应急移动电源预配置和动态调度(下)—MPS动态调度(Matlab代码实现)内容概要:本文档围绕“基于配电网韧性提升的应急移动电源预配置和动态调度”主题,重点介绍MPS(Mobile Power Sources)动态调度的Matlab代码实现,是SCI一区论文复现的技术资料。内容涵盖在灾害或故障等极端场景下,如何通过优化算法对应急移动电源进行科学调度,以提升配电网在突发事件中的恢复能力与供电可靠性。文档强调采用先进的智能优化算法进行建模求解,并结合IEEE标准测试系统(如IEEE33节点)进行仿真验证,具有较强的学术前沿性和工程应用价值。; 适合人群:具备电力系统基础知识和Matlab编程能力,从事电力系统优化、配电网韧性、应急电源调度等相关领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①用于复现高水平期刊(SCI一区、IEEE顶刊)中关于配电网韧性与移动电源调度的研究成果;②支撑科研项目中的模型构建与算法开发,提升配电网在故障后的快速恢复能力;③为电力系统应急调度策略提供仿真工具与技术参考。; 阅读建议:建议结合前篇“MPS预配置”内容系统学习,重点关注动态调度模型的数学建模、目标函数设计与Matlab代码实现细节,建议配合YALMIP等优化工具包进行仿真实验,并参考文中提供的网盘资源获取完整代码与数据。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值