I am trying this problem but when i am submitting it to spoj it gives WA.if spoj is giving wrong answer then its obvious that i am wrong at some input,but its very difficult to figure out in which case i am wrong.Plz provide some more test cases or tell where my code is wrong
below is my code for the problem
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
int main()
{ string s=" ";
int t=1;
int n=0,time;
string times;
getline(cin,times,'\n');
time=atoi(times.c_str());
while(time--)
{
string line;
getline(cin,line,'\n');
char ch;
int i,j,k;
i=j=k=0;
for(i;i<line.length();i++)
{
ch=line[i];
if(ch=='[')
{j++;}
if(ch==']')
{break;}
}
for(int i=line.length()-1;i>=0;i--)
{
ch=line[i];
if(ch==']')
{k++;}
if(ch=='[')
{break;}
}
if(j>=k)
{cout<<t<<s<<pow(2,j)<<endl;t++;}
else
{cout<<t<<s<<pow(2,k)<<endl;t++;}
}
}