|
|
back to boardAbout Java... Posted by DWED 7 Aug 2008 18:17 Java on this server is EXTREMELY slow! Moreover - it is really strange - don't you ever notice how it gives you "Compilation Error" on @Overriden annotation automatically generated by Eclipse. On maximal set (K100 graph) on my P4 3GHz my last solution works 0.03s, on server it works 5 times longer - 0.17s! Fantastic! Initially on my machine solution worked 0.400s - it is TLE, no words. To make it faster I tried to avoid all collections. I thought "DAMN! They want all programmers to write like with raw C/Pascal". After I've finished, it worked 0.360s - so collections did not a great slowdown. "Output is slow?" I constructed output in StringBuffer, and "viola" - twice speed-up (0.170s). "That's enough" - I thought and got TLE again - now i know about 5x time scale, but then... I switched of my algo and output and found that all time (0.150s) is taken by input. I did input with Scanner class, now it is time to throw it away. Just a simple method for input: >public final static int nextInt() throws IOException { >>InputStream in = System.in; >>int i = in.read() - 48; >>while (i<0) { >>>i = in.read() - 48; >>} >>int ret = i; >>i = in.read() - 48; >>while (i>=0) { >>>ret = (10*ret) + i; >>>i = in.read() - 48; >>} >>return ret; >} "Bingo!" - my solution now works 0.03s. But on server it is 0.03x5=0.15. So BEWARE! Re: About Java... I suppose that's because server use JDK1.5, not 1.6 Re: About Java... Maybe their method of calculating Running time is different |
|
|