Https://www.codechef.com/viewsolution/44998964

https://www.codechef.com/viewsolution/44998964

Can anyone tell whats is wrong with my solution, it passes all the test cases and i myself tried some test cases it went well but while submitting i am getting wrong answer?

Consider the test input:

1
++

Yes after posting i immediately got this test case so i was going to update the link, i have updated solution but still.
https://www.codechef.com/viewsolution/44999368

1 Like
1
+++

thankyou got it

1 Like

still not getting submission.
why??

Link?

https://www.codechef.com/viewsolution/44999621

1
++++---+
/*-------------- Sameer Vats --------------- */
#include<bits/stdc++.h>
using namespace std;
#define fast_io ios::sync_with_stdio(false);cin.tie(NULL)
#define szt size_t
#define pb push_back
#define pp pop_back
#define nl '\n'
#define MOD 1000000007
#define INF 1e18


void solve()
{
   string s;
    cin>>s;
    int i,cnt1=0,cnt2=0;
    for(i=0;i<s.length();i++)
    {
        if(i%2==0 && s[i]!='+')
            cnt1++;
        else if(i%2!=0 && s[i]!='-')
            cnt1++;
      }

    for(i=0;i<s.length();i++)
      {
        if(i%2==0 && s[i]!='-')
            cnt2++;
        else if(i%2!=0 && s[i]!='+')
            cnt2++;
      }

    if(cnt1 < cnt2)
        cout<<cnt1<<endl;
    else
        cout<<cnt2<<endl;
}

int main(){
  fast_io;
  
  solve();
  return 0;
}