QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#697766#9430. Left Shifting 2He_ngWA 0ms3532kbC++201.1kb2024-11-01 15:40:542024-11-01 15:40:55

Judging History

你现在查看的是最新测评结果

  • [2024-11-01 15:40:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3532kb
  • [2024-11-01 15:40:54]
  • 提交

answer

#include <bits/stdc++.h>
const int P = 998244353;
typedef long long ll;
#define rep(i, x, y) for (int i = (x); i <= (y); ++i)
using namespace std;
void solve()
{
    string s;
    cin >> s;
    int n = s.length();
    bool op = false;
    int cnt1 = 0;
    s = " " + s;
    string x;
    rep(i, 1, n)
    {
        int pos = i;
        while (pos <= n && s[pos] == s[i])
            pos++;
        int cnt = pos - i;
        if (cnt % 2 == 0 && (cnt >= 2))
        {
            cnt1 = i;
            break;
        }
        i = pos - 1;
    }
    if (cnt1)
    {
        x = s.substr(cnt1 + 1);
        x += s.substr(1, cnt1);
        x = " " + x;
    }
    else
        x = s;
    int ans = 0;
    cout << x << endl;
    rep(i, 1, n)
    {
        int pos = i;
        while (pos <= n && x[pos] == x[i])
            pos++;
        int cnt = pos - i;
        ans += cnt / 2;
        i = pos - 1;
    }
    cout << ans << endl;
    return;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}
/*
3
abccbbbbd
abcde
x
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3532kb

input:

3
abccbbbbd
abcde
x

output:

 cbbbbdabc
2
 abcde
0
 x
0

result:

wrong answer 1st lines differ - expected: '2', found: ' cbbbbdabc'