QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#657051#9430. Left Shifting 2PollockWA 4ms3528kbC++171.3kb2024-10-19 14:06:222024-10-19 14:06:29

Judging History

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

  • [2024-10-19 14:06:29]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3528kb
  • [2024-10-19 14:06:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
//#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define TEXT freopen("azerah.in","r",stdin); freopen("azerah.out","w",stdout);
#define testcase int TT; cin >> TT; for (int tc = 1; tc <= TT; tc++)
#define POL(i,n) for (int i = 0 ; i < n ; ++i)
#define pb push_back
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define F first
#define S second
//#define endl "\n"
typedef pair<int,int>PL;



void solve()
{
    string s;
    cin >> s;
    int n=s.size();
    s=' '+s;
    int l=1,r=n,cnt=0;
    vector<int>v;

    for(int i=1;i<=n;i++)
    {
        if(s[i]==s[1])l++,cnt++;
    }
    for(int i=n;i>=l;i--)
    {
        if(s[i]==s[1])r--,cnt++;
    }
    v.pb(cnt);
    int c=1,f=0,ans=0;
    for(int i=l+1;i<=r;i++)
    {
        if(s[i]==s[i-1])
        {
            c++;
        }
        else
        {
            v.pb(c);
            c=1;
        }
    }
    v.pb(c);
    for(auto it:v)
    {
        ans+=(it/2);
        if((it%2)==0)f=1;
    }
    cout << ans-f << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    testcase
    {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3524kb

input:

3
abccbbbbd
abcde
x

output:

2
0
0

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 3528kb

input:

5000
lfpbavjsmppdppkfwnyfmbdhptdswsoulrbhyjh
cfliuqnynejgnxolzbdoztclzbozqomvioszk
eiivcoqoymonrqgrjdtkts
mdcvservaxcbioopfungsgkiftchwlmtbzqgaraovjknsgiegkvdbolmeunvrxrpscnf
ujeqtidwtoikkqtygo
llma
qjfvgwrdhaazejsfgilnpmmhkefndzvyon
kzwwpdpbrudqmwmjscllnnjyoepxophcoopvfepikouinuxx
vftculoorxskpkxoz...

output:

2
1
0
2
0
0
1
4
0
0
4
1
1
2
1
8
1
1
6
10
4
0
7
5
0
2
4
6
1
4
2
1
2
1
4
1
1
6
4
5
1
1
1
6
6
0
4
1
0
3
10
0
0
9
4
2
1
4
1
3
7
2
4
7
5
1
4
6
7
0
5
2
3
0
4
0
3
5
2
6
2
8
8
1
8
0
5
1
1
3
3
0
8
1
2
7
4
3
1
3
5
5
5
3
4
1
6
6
4
9
0
1
9
1
6
7
8
5
2
6
0
3
7
0
3
1
3
7
6
1
6
1
1
2
8
4
3
6
1
2
2
3
1
1
4
3
5
2
2
...

result:

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