1 / 14
Jan 2012

RE-Edit : it seems it's a bug related with the data in the problem (novice24)

I'm very confident with my 62936908 submission.

But I got runtime error (NZEC)
Strong tests are OK on my machine and on IdeOne too.

As there is still no Python3 solutions, it could be a bug with the judge.

Can someone take a look.
Many thanks.

  • created

    Jan '12
  • last reply

    Jun '20
  • 13

    replies

  • 1.1k

    views

  • 5

    users

  • 4

    links

No one on the forum can see your code submissions. Please post your code.

Sorry to insist, but my code is good.
Today there is only NZEC Python3 solution : it's a sign !

Python3 coders are all rookies or there is a bug.
(Python2 is not affected)

I think it's not related to novice24.
(I'll edit first post)

It's not a bug of Python3, it's the input data of NOVICE24 that is broken.
There is at least one line that has more than one value and thus there are less lines than t states.
Solution: Read the whole input in one piece as string and split that string.

Thanks for the answer.

Is this kind of reading could give me AC ?

def nextPrime(n):
 return # snip
from sys import stdin, stdout
input()
for line in stdin:
  for m in line.split():
    n = int(m)
    stdout.write(str(nextPrime(n))+"\n")

I get WA now .

=========
Edit : on the clone problem4,
I got AC.

How to read correct datas from NOVICE24 ?

BR

No. You're still reading line by line, which requires an EOL mark at the end of a line.
The input of NOVICE24 is broken, as I stated above, i.e. some (or all?) values are not separated by an EOL, but by spaces or tabs.
As this doesn't effect the typical way of reading these kind of data in languages like C/C++ and others, it is often not noticed until a language (like Python and some others) is used, where this effects the typical way of reading input from stdin.

Indeed the documentation of the standard-library for Python 3.x is worse than that for Python 2.x at that point, but if you read the chapter about file objects in the Python 2.6 standardlib docu that should help to find out, how you can read the whole(!) input as a single string, that can be processed afterwards: http://docs.python.org/release/2.6.6/library/stdtypes.html#file-objects2

@Moderators: Thread should perhaps be moved to Python section.

I still get WA with this kind of reading :

from sys import stdin, stdout
input()
#stdout.write("\n".join(map(str, map(nextPrime, map(int, stdin)))))
for line in stdin:
  for m in line.split():
    n = int(m)
    stdout.write(str(nextPrime(n))+"\n")
reste = stdin.read().split()
for x in reste:
  stdout.write(str(nextPrime(int(x)))+"\n")

Can an administrator fix the input file and/or move this thread to the python section,
please.

Best Regards

Something like this should work:

import sys
for i in map(int,sys.stdin.read().strip().split()[1:]):
    ... your algo

Sometimes I even give the to be stripped characters as arguments.

Thanks, I got AC.
I think the problem is in the first line !!!
It is possible that all the data are on a unique line !!!

Regarding my piece of code above:
For the particular input data set you it should even work without the strip as there are only single numbers per test case. The split would eliminate all rubbish.

As I posted before: Read the whole input as one single string and process it ... (that's what hendrik's code does).
You find that documented if you follow the link in my former post.

Many thanks for the good link.
I first don't had imagined that the problem could be yet in the first line, so I had stupidly insisted with a first input()...
So after that, it's possible that the problem is on the first line !!! (just a supposition)


I recommend instead of NOVICE24, the problem Prime After N2 wich has a stronger input request and no problem with the input method.

Many of the problems that are in Tutorial are not there because they are good tutorials... They are there because they were deemed not worthy of the Classical scoring. They were either too easy, duplicates of another problem, or flawed. That's what I have noticed in my experience around here.

8 years later