Help me in solving ALBS problem

My issue

What should be the right answer for ‘000’?
Shouldn’t it be “1” operation as the string would become ‘010’?
In testcase the answer says “2”.

My code

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

int main() {
	// your code goes here
	int t=0;
	cin>>t;
	while(t--)
	{
	    int n=0,b=0,c=0,f=0;
	    cin>>n;
	    string s;
	    int a[n];
	    cin>>s;
	    if(n==1) {cout<<"0\n";continue;}
	    for(int i=0;i<n;i++) a[i]=s[i]-'0';
	    b=a[0];
	    for(int i=1;i<n-1;i++)
	    {
	        f=1;
	        if(a[i]!=a[i-1])
	        {
	            if(a[i]!=a[i+1])
	            {
	                continue;
	            }
	            else
	            {
	                c+=1;a[i+1]=a[i-1];
	            }
	        }
	        else
	        {
	            c+=1;
	            if(a[i+1]==a[i])
	            {
	                if(a[i]==0) a[i]=1; else a[i]=0;
	            }
	        }
	    }
	    if(f==0)
	    {
	        if(a[0]==a[1]) c=1;
	    }
	    cout<<c<<"\n";
	}

}

Problem Link: Alternating Binary String Practice Coding Problem - CodeChef

You need 2 operations to become 000 into 010.

1- 001
2- 010

Remember that all the numbers after the index are also flipped.