跳转至

Educational Codeforces Round 149 (Rated for Div. 2)

2025-03-25

这场太抽象 ABCD 800-900-1000-1400

相当于写了一点帮助没有,EF难度有点太高,暂时不打算补

比赛链接: https://codeforces.com/contest/1837

A

void ChatGptDeepSeek()
{
    int x,k;
    cin>>x>>k;
    if(x%k==0){
        cout<<"2\n";
        cout<<"1 "<<x-1<<'\n';
    }else cout<<"1\n"<<x<<'\n';
}

B

void ChatGptDeepSeek()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0, cnt = 1;
    for (int i = 1; i < s.size(); i++)
    {
        if (s[i] != s[i - 1])
        {
            ans = max(ans, cnt + 1);
            cnt = 1;
        }
        else
            cnt++;
    }
    ans = max(cnt + 1, ans);
    cout << ans << '\n';
}

C

void ChatGptDeepSeek()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != '?')
        {
            int j = i - 1;
            while (j >= 0)
            {
                s[j] = s[i];
                j--;
            }
            break;
        }
    }
    if (s[0] == '?')
    {
        string t(s.size(), '0');
        cout << t << '\n';
        return;
    }
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '?')
            s[i] = s[i - 1];
    }
    cout << s << '\n';
}

D

void ChatGptDeepSeek()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0, color = 0;
    char lst = s[0];
    vector<int> ans;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '(')
            cnt++;
        else
            cnt--;
        if (cnt > 0 && lst != '(')
            color ^= 1, lst = '(';
        else if (cnt < 0 && lst != ')')
            color ^= 1, lst = ')';
        ans.push_back(1 + color);
    }
    if (cnt != 0)
    {
        cout << "-1\n";
        return;
    }
    cout << *max_element(ans.begin(), ans.end()) << '\n';
    for (auto x : ans)
        cout << x << " ";
    cout << '\n';
    /*
     */
}