15 / 83
Jul 2004

Great, thanks!

Hey, I see you have been doing some private investigation wink

Yes, it would be cool to have Nice added. I will try problems once in a while, and I will point to your project on our mailing list once it is. It's motivating to have tasks like this when you are learning a new language.

Technically, if the judge is like a server a Debian machine, you can

apt-get install nice

Oops, submitted by accident.

If you want to accept a single nice source file as entry, you can compile it like this: put it file with '.nice' extension in a 'main' subdirectory, then call

nicec --classpath <external libraries> -a main.jar main

and then run with

java -classpath main.jar:<external libraries> main.dispatch

The idea is the same external libraries that are available for Java programs could also be used in Nice programs.

Thanks. When Noix gets back from holiday (perhaps today?) we will add the two new languages. Once we are about it, I think we will try to modify the system in such a way as to keep one jdk installation for "java", "nice" and "bytecode-java" (to improve maintainability).

BTW. I wonder whether jre1.3.1 would work with a newer class library?

You mean use the classes from JDK 1.4 with the VM of 1.3? Why would you want to do that?
In any case, it seems it wouldn't work (here with 1.4 and 1.5beta):

java -Xbootclasspath:/usr/local/opt/jdk1.5.0/jre/lib/rt.jar
Error occurred during initialization of VM
java.lang.NoSuchMethodError: java.lang.Thread.start()V

"Bytecode" language is added (simply send a .jar) smile We'll also add Nice, probably today..

Great, thanks a lot!

How are jars handled at the moment? Started with Main, the main-class in the manifest, both?

At present - with Main. We will add the manifest option when configuring Nice.

Is it possible to disable the inclusion of standard (library) classes in the jar file generated by the Nice compiler?

Not directly. Is that a problem?

I know the jar will be above the default limit, but that should not matter when submitting Nice source, right? Also, it's possible to use a tool to cut down on dead code. I tried proguard, and a simple Nice program gives a 17K jar file.

OK, jar files with/without manifests are now supported. Nice compiled to Bytecode works for TEST in 0.99s. The Nice compiler will be made available tomorrow.

Cool! I just solved TEST in 0.89s. Must have found a more clever algorithm wink

Did you also use a tool to cut down the size, or did you internally bypass the size limit to run a nice program as JAR?

I just changed the submission size limit for the problem TEST for a moment wink.

But thanks for mentioning proguard; I hadn't realised that there existed an open source java obfuscator. These can get quite handy sometimes, especially if privacy (not necessarily secrecy) of source code is required.

1 month later

I tried to use the JAVA class: com.braju.beta.format.Format and I am getting a compilation error. I read in a post that was added manually into the classpath...is it true? I was trying to see the diference between this and the standard InputStream reader for the palindrome problem.

regards

Raul

I am afraid the post you are referring to was a little out of date. Indeed, until about a month ago we were using Blackdown JAVA 1.3, and the com.braju.beta.format.Format was available (it worked about twice as slowly as normal IO).

This class was not included in the new Java installation (Sun JAVA 1.5 beta2) for the simple reason, that the newly added standard classes java.util.Scanner and Formatter (as well as the printf method for some other classes) seemed to make it redundant.

Please note that since Sun's JDK 1.5 beta2 differs significantly from 1.5 beta1, and is much closer to the current ReleaseCandidate, you should only use the official documentation of these classes, and not other sources found in the Internet (since they are mostly out of date).

The following is an example of code that will work with the online judge:

import java.util.Scanner;
class Main
{
   public static void main (String [] args)
   {
      /*
         // equivalent C code fragment
         int i;
         float f;
         char s [50];
         printf ("Enter three values -- integer float string: ");
         scanf ("%d %f %s", &i, &f, s);
         printf ("%d %f %s\n", i, f, s);
      */
      System.out.printf ("Enter three values -- " +
                        "integer float string: ");
      Scanner sc = new Scanner (System.in);
      int i = sc.nextInt ();
      float f = sc.nextFloat ();
      String s = sc.nextLine ();
      System.out.printf ("%d %f %s\n", i, f, s);
   }
}

But if you find that these classes do not meet your requirements, please let us know and we will add com.braju.beta.format to the classpath; this is no problem whatsoever.

Glup...well, not a nice increase in performance.

Seems pretty nice, thanks a lot.

Raul

1 year later

SPOJ is not accepting my code? cry

Both solutions mentioned above also give wrong answer! open_mouth

Why does SPOJ says that this code gives wrong answer? Any one who solved this in SPOJ please help.

they say, it will be 1 or 2 digits only. they won't test 421 on the code. so chill smile

1 year later

Hello,
does anybody know why my code is not accepted? I get "runtime error (NZEC)". Earlier when I additionally surrounded the code-line "x = eingabe()" with a try-catch block in order to catch a NumberFormatException from the parseInt()-method i even got "time limit exceeded"... On my machine it works correctly. Here is my code:

import java.util.Iterator;
import java.util.LinkedList;
public class Main
{
	public static void main(String[] args)
	{
		int x;
		LinkedList<Integer> l = new LinkedList<Integer>();
		while(true)
		{
			x = eingabe();
			if(x != 42)
			{
				l.add(new Integer(x));
			}
			else
			{
				break;
			}
		}
		for(Iterator<Integer> i = l.iterator();i.hasNext();)
		{
			System.out.println(i.next());
		}
      System.exit(0);
	}
	static int eingabe()
	{
		String s = "";
		try
		{
			s = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)).readLine();
		}
		catch (java.io.IOException e)
		{
		}
		return java.lang.Integer.parseInt(s);
	}	
}