I prepared several testcases and each one is passing as per the rules 
stated in the problem. But still I get WA: wrong answer. Could anyone point 
me out to a possible case where my solution fails? It'd be great help

#include <iostream>
#include <string>
#include <deque>
using namespace std;

int main()
{ 
int T , N ;
cin >> T ;
for(int it = 1 ; it <= T ; ++it)
{
    string input ;
string output ;
        cin >> input ;
int nc_open = 0 ;
deque<char> tailstr ;
for(auto digit : input)
{
int num = digit - '0' ;
if(nc_open <= num)
{
int nc_add = num - nc_open ;
string temp(nc_add, '(');
temp += digit ;
output += temp;
for(int k = 0 ; k < nc_add ; ++k)
{
    tailstr.push_back(')');
}
nc_open = num;
}
else
{
int extra_par = nc_open - num ;
for(auto i = 1 ; i <= extra_par ; ++i)
{
output += tailstr.back();
tailstr.pop_back();
}
nc_open = num ;
output += digit ;
}
}
for(auto ch: tailstr)
output += ch ;
output += '\0' ;
cout << "Case #"<< it << ": " << output << endl;
}
return 0 ;
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-code+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/01d37eda-10e8-4ce8-af65-0efc4c9d8859%40googlegroups.com.

Reply via email to