The issue seems to be caused by the line 
output+='\0'
on line 48. Since the code prints a new line character with endl, the \0 is 
redundant, causing that pesky WA error. I ran your code without adding the 
\0 to the output, and it passed both test cases. Hope this helps!

Best,
Matt


On Monday, April 6, 2020 at 8:56:20 PM UTC-4, Avinash Bhardwaj wrote:
>
>
> 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/d1b8130b-3a59-4115-93d7-bbe7bbadd29c%40googlegroups.com.

Reply via email to