1 / 3
Jan 2015

i'm getting run time error for this question.
first i thought it's because of some input format error but it's giving me
runtime error even when i used (tokenization, stdin.read().split()). and i don't
think my algo is wrong because the same algo in c++ gave me AC.

my python code.

#!/usr/bin/env python
# encoding: utf-8
from itertools import groupby
from sys import stdin
def main():
    inp = stdin.read().split()
    for _ in xrange(int(inp[0])):
        prod = 0
        for item, it in groupby(inp[_ + 1]):
            prod += ... # edited by Francky
main()

my C++ code

//removed
  • created

    Jan '15
  • last reply

    Jan '15
  • 2

    replies

  • 448

    views

  • 3

    users

I too think there's some issue with input.
I couldn't (long time ago) manage to get AC with Python, although I got it with C.

I removed your code, as it is only an input reading issue.

Indeed it's an input issue. You will have read the comments on the problem page, there are some hints according that.
If you don't want to bother with that, choose another language.