HDU BestCoder Round #48 1001

本文介绍了一个简单的编程问题:如何判断字符串“wyh”是否为给定字符串的子序列,特别考虑了连续字符被视为单一字符的情况。通过示例输入输出展示了问题场景,并提供了一段C++代码实现解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

                                         wyh2000 and a string problem

                                         Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)

Problem Description
Young theoretical computer scientist wyh2000 is teaching young pupils some basic concepts about strings.

A subsequence of a string s is a string that can be derived from s by deleting some characters without changing the order of the remaining characters. You can delete all the characters or none, or only some of the characters.

He also teaches the pupils how to determine if a string is a subsequence of another string. For example, when you are asked to judge whetherwyh is a subsequence of some string or not, you just need to find a character w, a y, and an h, so that the w is in front of the y, and the y is in front of the h.

One day a pupil holding a string asks him, "Is wyh a subsequence of this string?"
However, wyh2000 has severe myopia. If there are two or more consecutive charactervs, then he would see it as one w. For example, the string vvv will be seen as w, the string vvwvvv will be seen as www, and the string vwvv will be seen as vww.

How would wyh2000 answer this question?
 

Input
The first line of the input contains an integer T(T105), denoting the number of testcases.

N lines follow, each line contains a string.

Total string length will not exceed 3145728. Strings contain only lowercase letters.

The length of hack input must be no more than 100000.
 

Output
For each string, you should output one line containing one word. OutputYes if wyh2000 would consider wyh as a subsequence of it, or No otherwise.
 

Sample Input
4 woshiyangli woyeshiyangli vvuuyeh vuvuyeh
 

Sample Output
No Yes Yes No
水题还会错,唉,刚开始套了三层循环,一直超时,额,不超时才怪。

#include <iostream>
#define maxn 3145728+5
#include <string.h>
#include <stdio.h>
using namespace std;

char c[maxn],a[4]="wyh";
int main()
{
    int n;
    cin>>n;
    int flag;
    while(n--)
    {  // memset(c,0,sizeof(c));
        scanf("%s",c);
        flag=0;
        int cnt=0;
        int len=strlen(c);
        //cout<<len<<endl;
        c[len]='a';
        c[len+1]='\0';
        for(int i=0; i<len; i++)
        {
            if(c[i]=='v'&&c[i+1]=='v')
            c[i]='w';
            if(c[i]==a[cnt])
            cnt++;
            if(cnt==3)
            break;

        }
        if(cnt==3)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;
    }
    return 0;
}



内容概要:本文针对火电厂参与直购交易挤占风电上网空间的问题,提出了一种风火打捆参与大用户直购交易的新模式。通过分析可再生能源配额机制下的双边博弈关系,建立了基于动态非合作博弈理论的博弈模型,以直购电价和直购电量为决策变量,实现双方收益均衡最大化。论文论证了纳什均衡的存在性,并提出了基于纳什谈判法的风-火利益分配方法。算例结果表明,该模式能够增加各方收益、促进风电消纳并提高电网灵活性。文中详细介绍了模型构建、成本计算和博弈均衡的实现过程,并通过Python代码复现了模型,包括参数定义、收益函数、纳什均衡求解、利益分配及可视化分析等功能。 适合人群:电力系统研究人员、能源政策制定者、从事电力市场交易的工程师和分析师。 使用场景及目标:①帮助理解风火打捆参与大用户直购交易的博弈机制;②为电力市场设计提供理论依据和技术支持;③评估不同政策(如可再生能源配额)对电力市场的影响;④通过代码实现和可视化工具辅助教学和研究。 其他说明:该研究不仅提供了理论分析,还通过详细的代码实现和算例验证了模型的有效性,为实际应用提供了参考。此外,论文还探讨了不同场景下的敏感性分析,如证书价格、风电比例等对市场结果的影响,进一步丰富了研究内容。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值