COMPILER - Editorial

ad-hoc
compiler
easy
editorial
may14

#41

Mine is here - http://www.codechef.com/viewsolution/3815607


#42

combination of statements

char* a[500];
// ...
a[m][j]

is strange isn’t it?


#43

Actually,
i used to work on Turbo c++ and it used to work on it.
and also i am new to codeshef.
But Yes It seems strange,
http://ideone.com/ObhNFA,
its working now but ,
time limit exceed,
but i m trying to develop better logic.


#44

You was kind of lucky, your code is not working on ideone I had to change

Scanner s = new Scanner(System.in);
String str = s.nextLine();

to

//Scanner s = new Scanner(System.in);
String str = rea.nextLine();

and the code returns 0 4 0 for input from problem statement http://ideone.com/UyDMNu , can you fork it and fix it on ideone?


#45

Your code is not working on ideone, can you fix it? http://ideone.com/1AnFUY I used your last submission in practice…


#46

try this test case <<>.The answer should be 0 , but ur code gives 2.


#47

@rishab
why so coz <<> last two brackets are matching which is the case with the official test case of <>>> which gives 2 as output.
plz clarify it :frowning:


#48

you should output the length of the longest prefix


#49

thanku got it :stuck_out_tongue:


#50

ad hoc means something that is not known in advance


#51

ANswer for ><<>> should be 0


#52

Why so ?? I can see that I have valid string of length 4 here


#53

Read the problem statement carefully it has asked for length of longest valid ‘prefix’ , so the expression must start with ‘<’. Hope it helps!


#54

They have asked “Prefix”. Read question again. Even first ‘>’ gives answer 0 as there is no valid prefix. There is no need to check further.


#55

https://www.codechef.com/viewsolution/24353005
is my code, please let me know where’s the mistake.
I tried various test cases and they display correct output. I used pair parentheses algorithm to solve it and have then multiplied the count object by 2 to get the output.