COMPILER - Editorial - CodeChef Discuss

Embed Size (px)

Citation preview

  • 8/12/2019 COMPILER - Editorial - CodeChef Discuss

    1/4

    6/17/2014 COMPILER - Editorial - CodeChef Discuss

    http://discuss.codechef.com/questions/42551/compiler-editorial 1/4

    Follow this questionBy Email:You are not subscribed to this questi

    subscribe me

    (you can adjust your notificationsettings on your profile )

    By RSS: Answers

    Answers and Comments

    Tags:

    editorial 785

    easy 332

    ad-hoc 56

    compiler 37

    may14 10

    Asked: 12 May, 15:09

    Seen: 1,143 times

    Last updated: yesterday

    Related questions

    RRSTONE - Editorial

    BALLS - Editorial

    ROC - Editorial

    OJUMPS - Editorial

    IITI14 - Editorial

    PPNUM - Editorial

    LUCKY8 - Editorial

    SUBSTR - Editorial

    CHEFBM - Editorial

    DIREL - Editorial

    questions tags users badges unanswered ask a question a

    krutarthkp800 1 L

    The old forum can be v iewed here . Seek help .

    CodeChef Discussion Search Here... questions tags users

    7

    1

    ad-hoc may14 easy editorial compilerThis question is marked "community wiki".

    asked 12 May, 15:09

    darkshadows 2.7k 54 87 93accept rate: 7%edited 12 May, 17:19

    13 Answers:

    0 link | award points answered 12 May, 16:23zitu_cuet1accept rate: 0%

    COMPILER - Editorial

    PROBLEM LINK:Practice Contest

    Author: Bruno Oliveira Tester: Sergey Kulik Editorialist: Lalit Kundu

    DIFFICULTY:EASY

    PRE REQUISITES:AD-HOC

    PROBLEM:Given a bracket sequence, print the length of largest prefix that is a regular bracket sequence.

    EXPLANATION:A regular bracket sequence i s defin ed as follo ws:1. S="" is regular.2. S="" i s regular, if S1 is regular.3. S=S1 concat S2 is regular, is S1 and S2 are regular.

    If S is regular bracket sequence, for any i, number of closing brackets in S[0,i] should n ot exceed n umber of opening brackets.

    Also, if number of opening brackets is equal to number of closing brackets in S[0,i], S[0,i] is a regular bracket sequence.

    def check(s):

    t=0,ans=0

    for i=0 to N-1:

    if s[i]=='

  • 8/12/2019 COMPILER - Editorial - CodeChef Discuss

    2/4

    6/17/2014 COMPILER - Editorial - CodeChef Discuss

    http://discuss.codechef.com/questions/42551/compiler-editorial 2/4

    0 link | award points answered 12 May, 17:39

    gaurav_bhumika1accept rate: 0%

    0 link | award points answered 12 May, 20:49

    ashish1610111 137accept rate: 11 %

    0

    link | award points answered 12 May, 23:21

    masif1accept rate: 0%

    0 link | award points answered 13 May, 01:44

    saopayne11accept rate: 0%

    0 link | award points answered 13 May, 15:12

    mjbpl30625accept rate: 5%

    add new comment

    can i get sometest cases want to figure out where i am getting wrong, comipler of codeshef was flashing WRONG ANSWER

    add new comment

    Can anyone tell me why my this Pascal code was giving wrong ans but same implementation in C++ passed ?

    add new comment

    Can somebody please tell me the mistake that I did in this C code: http://ideone.com/HcmfNJ

    Got a WA.. :'(

    add new comment

    Can anyone post a java implementation for this?

    add new comment

    Incidentally a similar question was asked on forums a few month's back.

    (12 May, 16:26)mukit_mkbs

    Output should be 6

    (12 May, 16:34)zitu_cuet

    Thanks got it!!! :P :P

    (12 May, 17:59)betlista

    1 You assume, that max input length is 100, why?

    See the second test case - http://ideone.com/Xxe1sf (answer is not 4 for sure)

    (12 May, 19:04)gaurav_bhumika

    http://ideone.com/LjfGNp Can you help me where i m getting wrong thank you so much

    (13 May, 04:10)betlista

    1 combination of statements

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

    is strange isn't it?

    (13 May, 12:40)gaurav_bhumika

    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.

    (13 May, 00:21)betlista

    for input

    1

  • 8/12/2019 COMPILER - Editorial - CodeChef Discuss

    3/4

    6/17/2014 COMPILER - Editorial - CodeChef Discuss

    http://discuss.codechef.com/questions/42551/compiler-editorial 3/4

    0

    link | award points answered 14 May, 13:38

    subham_kumar61accept rate: 0%

    edited 14 May, 18:13

    betlista 11.7k 41 96 186

    0

    link | award points answered 14 May, 17:47

    srinivasam1accept rate: 0%

    0 link | award points answered 11 Jun, 10:25

    grvana0accept rate: 0%

    0 link | award points answered 11 Jun, 11:26

    brobear1995302accept rate: 0%

    add new comment

    Can anyone tell which case i am leaving ?? Have tried many times but cant get it Accepted.

    edit: http://www.codechef.com/viewsolution/3904670

    add new comment

    Please give a test case where my code fails for compilers and parsers [ http://www.codechef.com/viewsolution/3876116] the abovelink is the code where i had written in java

    add new comment

    why im getting WA for this. please help me with th is thanks in advance!! http://www.codechef.com/viewsolution/3900904

    add new comment

    what do you mean by ad-hoc? ( one of prerequisites)

    add new comment

    1 2 next

    Your answer

    (14 May, 18:15)betlista

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

    (14 May, 18:11)betlista

    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?

    (11 Jun, 10:47)rishabh1994

    try this test case which gives 2 as output. plz clarifyit :(

    (11 Jun, 12:29)betlista

    you should output the length of the longest prefix

    http://en.wikipedia.org/wiki/Substring#Prefix

    (yesterday)grvana

    thanku got it :P

    http://wmd-editor.com/http://discuss.codechef.com/vote/44436/down/http://discuss.codechef.com/vote/44436/up/http://discuss.codechef.com/users/12279/grvanahttp://discuss.codechef.com/like_comment/44783/http://en.wikipedia.org/wiki/Substring#Prefixhttp://discuss.codechef.com/users/1169/betlistahttp://discuss.codechef.com/like_comment/44443/http://discuss.codechef.com/users/43770/rishab94doshihttp://discuss.codechef.com/users/12279/grvanahttp://discuss.codechef.com/like_comment/44442/http://discuss.codechef.com/users/49438/rishabh1994http://discuss.codechef.com/like_comment/44426/http://discuss.codechef.com/vote/44425/down/http://discuss.codechef.com/vote/44425/up/http://ideone.com/UyDMNuhttp://system.in/http://system.in/http://discuss.codechef.com/users/1169/betlistahttp://discuss.codechef.com/like_comment/42849/http://discuss.codechef.com/vote/42848/down/http://discuss.codechef.com/vote/42848/up/http://ideone.com/1AnFUYhttp://discuss.codechef.com/users/1169/betlistahttp://discuss.codechef.com/like_comment/42850/http://discuss.codechef.com/vote/42824/down/http://discuss.codechef.com/vote/42824/up/http://discuss.codechef.com/questions/42551/compiler-editorial?sort=votes&page=2http://discuss.codechef.com/questions/42551/compiler-editorial?sort=votes&page=2http://www.codechef.com/viewsolution/3900904http://www.codechef.com/viewsolution/3876116]http://www.codechef.com/viewsolution/3904670http://discuss.codechef.com/users/60182/brobear1995http://discuss.codechef.com/award_points/user/60182/answer/44436/http://discuss.codechef.com/answer_link/44436/http://discuss.codechef.com/users/12279/grvanahttp://discuss.codechef.com/award_points/user/12279/answer/44425/http://discuss.codechef.com/answer_link/44425/http://discuss.codechef.com/users/58480/srinivasamhttp://discuss.codechef.com/award_points/user/58480/answer/42848/http://discuss.codechef.com/answer_link/42848/http://discuss.codechef.com/users/1169/betlistahttp://discuss.codechef.com/revisions/42824/http://discuss.codechef.com/users/19271/subham_kumarhttp://discuss.codechef.com/award_points/user/19271/answer/42824/http://discuss.codechef.com/answer_link/42824/
  • 8/12/2019 COMPILER - Editorial - CodeChef Discuss

    4/4

    6/17/2014 COMPILER - Editorial - CodeChef Discuss

    http://discuss.codechef.com/questions/42551/compiler-editorial 4/4

    Post Your Answer

    [hide preview] community wiki

    About CodeChef About Directi CEO's CornerCodeChef Campus Chapters CodeChef For Schools Contact Us

    2009, Directi Group. All Rights Reserved.Powered by OSQA

    http://www.codechef.com/contactushttp://www.codechef.com/school/http://www.codechef.com/campus/http://www.codechef.com/ceoscorner/http://www.directi.com/http://www.codechef.com/aboutus/http://www.directi.com/