Wrong Answer
Code
#include <bits/stdc++.h>
using namespace std;
void solv()
{
int n;
cin>>n;
string samp;
cin>>samp;
int sum = 0,flag = 0;
for(int i = 0; i < n - 1; i++)
{
if(samp[i] == '1' && samp[i+1] == '1')
{
sum++;
}
else if(samp[i] == '1')
{
flag = 1;
}
else {
continue;
}
}
if(flag == 1 && sum == 0)
{
cout<<1<<endl;
}
else
{
cout<<sum<<endl;
}
}
int main()
{
int t;
cin>>t;
while(t--)
{
solv();
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1113 Fliping Game
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-11-05 22:00:11
- Judged At
- 2024-11-05 22:00:11
- Judged By
- Score
- 5
- Total Time
- 15ms
- Peak Memory
- 540.0 KiB