2025-11-10

CF

Problem - 1084C - Codeforces

简单题,算每一块中a的数量,对于每一块,有选0,1,2……,k种,k+1种选法

#include <bits/stdc++.h>
using namespace std;
#define LL long long
const LL mod = 1e9+7;
const int N=2e5+10;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    vector<int> a;
    for (int i = 0; i < s.size(); i++)
    {
        int cnt = 0;
        while (i < s.size() && s[i] != 'b')
        {
            if (s[i] == 'a')
            {
                cnt++;
            }
            i++;
        }
        a.push_back(cnt);
    }
    int res = 1;
    for (int i = 0; i < a.size(); i++)
    {
        res = ((LL)res * (a[i] + 1)) % mod;
    }
    cout << res - 1 << endl; // 删去全不选的情况
}

CF1063B

Problem - B - Codeforces

思维题,卡了两小时还没做出来
今天这场只做出来A呜呜呜
5次的操作数,就应该去考虑怎么通过5次操作把所有数覆盖住

#include <bits/stdc++.h>
using namespace std;
#define LL long long
const LL mod = 998244353;
const int N=2e5+10;
int a[N], pos[N];

void solve()
{
    int n;
    cin >> n;
    for (int i = 0; i < n;i++){
        cin >> a[i];
        pos[a[i]] = i;
    }
    string s;
    cin >> s;
    if(s[0]=='1'||s[s.size()-1]=='1'||s[pos[1]]=='1'||s[pos[n]]=='1'){
        cout << -1 << endl;
        return;
    }
    cout << 5 << endl;
    cout << 1 << " " << pos[1] + 1 << endl;
    cout << 1 << " " << pos[n] + 1 << endl;
    cout << pos[1] + 1 << " " << n << endl;
    cout << pos[n] + 1 << " " << n << endl;
    cout << 1 << " " << n << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin >> T;
    while (T--)
    {
        solve();
    }
}
posted @ 2025-11-11 11:57  Seren_blingbling  阅读(2)  评论(0)    收藏  举报