You are not logged in. Please login at www.codechef.com to post your questions!

×

NZEC error in python for WSTRING

I got NZEC error in my submission. It works on my computer and I,ve got no idea what the problem is. Here is my code:

t=input();
while(t):
    s=raw_input()
    l=len(s)
    m=[0,0,0,0]
    j=0
    k=0
    ans=0
    while(j<l):
        d={}
        while(j<l and s[j]!='#'):
            if s[j] not in d.keys():
                d[s[j]]=1
            else:
                d[s[j]]+=1
            j+=1
        j+=1
        for n in range(0,3):
            m[n]=m[n+1]
        m[3]=max(d.values())
        k+=1
        an=m[0]+m[1]+m[2]+m[3]
        ans=max(an,ans)
    if k<4:
        print 0
    else:
        print ans+3
    t-=1

I'd appreciate any help.Thanks.

asked 18 Jun '13, 11:19

maneesh8484's gravatar image

2★maneesh8484
111
accept rate: 0%

edited 18 Jun '13, 11:39

kunal361's gravatar image

4★kunal361
6.0k133272


The submitted code can be seen here. http://www.codechef.com/viewsolution/2277945

link

answered 18 Jun '13, 11:23

maneesh8484's gravatar image

2★maneesh8484
111
accept rate: 0%

max(d.values()) makes no sense when d is empty.

it happens when there is a '##' in the input string.

link

answered 18 Jun '13, 22:37

cyberax's gravatar image

3★cyberax ♦
3.4k21955
accept rate: 20%

edited 18 Jun '13, 22:39

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×529
×435
×10

question asked: 18 Jun '13, 11:19

question was seen: 1,076 times

last updated: 18 Jun '13, 22:39