QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#657089 | #9430. Left Shifting 2 | Pollock | WA | 4ms | 3820kb | C++17 | 1.4kb | 2024-10-19 14:11:32 | 2024-10-19 14:11:33 |
Judging History
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=i+1;cnt++;
}
else break;
}
for(int i=n;i>=l;i--)
{
if(s[i]==s[1])
{
r=i-1;cnt++;
}
else break;
}
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: 3812kb
input:
3 abccbbbbd abcde x
output:
2 0 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 4ms
memory: 3820kb
input:
5000 lfpbavjsmppdppkfwnyfmbdhptdswsoulrbhyjh cfliuqnynejgnxolzbdoztclzbozqomvioszk eiivcoqoymonrqgrjdtkts mdcvservaxcbioopfungsgkiftchwlmtbzqgaraovjknsgiegkvdbolmeunvrxrpscnf ujeqtidwtoikkqtygo llma qjfvgwrdhaazejsfgilnpmmhkefndzvyon kzwwpdpbrudqmwmjscllnnjyoepxophcoopvfepikouinuxx vftculoorxskpkxoz...
output:
1 0 0 0 0 0 1 4 0 0 1 1 1 1 1 3 1 0 5 6 0 0 5 2 0 1 3 2 0 3 0 1 0 1 1 0 1 4 1 3 1 0 1 5 3 0 3 0 0 1 8 0 0 6 1 2 0 1 0 0 4 1 2 4 3 1 3 2 3 0 2 1 0 0 2 0 2 2 0 4 0 5 5 0 3 0 4 1 0 2 1 0 2 0 1 6 1 2 1 3 3 3 5 2 3 0 3 5 1 3 0 0 3 0 4 5 3 2 1 1 0 0 2 0 1 1 3 3 3 1 2 0 1 1 4 3 1 3 1 1 1 2 0 1 2 0 4 0 1 1 ...
result:
wrong answer 52nd lines differ - expected: '1', found: '0'