零点工作室暑假集训(AtCoder--ABC279)

A.wwwvvvvvv

题意:遇到 w就 +2(因为 w 可以看成两个 v ) , 遇到遇到v 就 +1

AC代码:

#include <iostream>
#include <algorithm>

using namespace std;

string s;
int ans;

int main()
{
    cin >> s;
    
    for(int i = 0; i < s.size(); i ++)
    {
        if(s[i] == 'v') ans ++;
        else ans += 2;
    }
    
    cout << ans << endl;
    
    return 0;

}

B .LOOKU

题意:给出字符串S和T,问字符串T是不是字符串S的子串。

思路:如果字符串T的长度大于字符串S,那么字符串T一定不可能是字符串S的子串。否则,枚举字符串S每个字母开始的长度与字符串T相同的子串,判断是否与字符串T相同。

AC代码:

#include <iostream>
#include <algorithm>

using namespace std;

string s, t;
int ans, k;

int main()
{
    cin >> s >> t;
    
    int x = s.size(), y = t.size();
    
    if(x < y)
    {
        cout << "No";
        return 0;
    }
    
    for(int i = 0; i < x; i ++)
    {
        ans = 0;
        k = i;
        for(int j = 0; j < y; j ++)
        {
           
            if(s[k] == t[j])
            {
                k ++;
                ans ++;
            }

            if(ans == y)
            {
                cout << "Yes";
                return 0;
            }
        }
    }
    
    cout << "No";
    
    
    
    return 0;

}

C .RANDOM

题意:给出 H 行 W 列的字符数组S和T,问是否有可能通过交换列使得这两个字符数组相同。

思路:只要将字符数组每列都存储一下,再通过枚举其中一个字符数组的列,寻找在另一个字符数组中是否有与其相同的列即可。

AC代码:

#include <iostream>

using namespace std;

const int N = 400010;

int num[N];
int h, w;

int main()
{
    cin >> h >> w;
    
    for (int i = 0; i < h; i ++) 
    {
        for (int j = 0; j < w; j ++) 
        {
            char s;
            cin >> s;
            
            if (s == '#') 
            {
                num[i] ++;
            }
        }
    }
    
    bool flag = true;
    
    for (int i = 0; i < h; i ++) 
    {
        int tmp = 0;
        for (int j = 0; j < w; j ++) 
        {
            char t;
            cin >> t;
            
            if (t == '#') 
            {
                tmp ++;
            }
        }
        
        if (num[i] != tmp) 
        {
            flag = false;
        }
    }
    
    if (flag) 
    {
        cout << "Yes" << endl;
    } 
    else 
    {
        cout << "No" << endl;
    }
    
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值