AcWing
  • 首页
  • 活动
  • 题库
  • 竞赛
  • 应用
  • 更多
    • 题解
    • 分享
    • 商店
    • 问答
  • 吐槽
  • 登录/注册

AcWing 3358. 放养但没有完全放养

作者: 作者的头像   Coinisi. ,  2023-01-25 10:26:30 ,  所有人可见 ,  阅读 3


0


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <unordered_map>
#include <unordered_set>

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#define IOS std::ios::sync_with_stdio(false)
#define pb push_back
#define inf 0x3f3f3f3f
#define YES cout << "YES" << endl;
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define NO cout << "NO" << endl;
#define int long long
#define x first
#define y second
#define cmp [&](PII a, PII b){ return a.y < b.y; }

const int N = 5e5+10, mod = 1e9+7, M = 1e6+5, K = 1e5+10, Z = 2e5+7;

using namespace std;
typedef long long LL;
typedef priority_queue<int> PQI; 
typedef priority_queue <int, vector<int>, greater<>> PQGI;
typedef pair<int, int> PII;

char str[1010], ch[27];

int get_idx(char c)
{
    for(int i = 1; i <= 26; i ++) 
        if(ch[i] == c) return i;
    return 0; 
}

void solve() 
{
    cin >> (ch + 1) >> (str + 1);

    int cnt = 1, t = strlen(str + 1);

    for(int i = 2; i <= t; i ++)
    {
        int s1 = get_idx(str[i]), s2 = get_idx(str[i - 1]);
        if(s1 <= s2) cnt ++;
    }

    cout << cnt << endl;
}

signed main()
{
    IOS; cin.tie(nullptr), cout.tie(nullptr); 
    int T = 1;
//    cin >> T;
    while( T -- ) solve();
    return 0;
}
//这里填你的代码^^
//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~

0 评论

你确定删除吗?
1024
x

© 2018-2023 AcWing 版权所有  |  京ICP备17053197号-1
用户协议  |  常见问题  |  联系我们
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标
请输入绑定的邮箱地址
请输入注册信息