ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1510. Order

java.util.Scanner
Posted by Konstantin Yovkov 15 Jun 2009 18:22
I got AC with O(n) ! Several times I got TL, but when I stopped reading the input with java.util.Scanner and started using java.io.BufferedReader it worked.

java.util.Scanner is too slow, don't use it !
Re: java.util.Scanner
Posted by alexey saybel 2 Feb 2010 14:02
thnx, otherwise TL21
Re: java.util.Scanner
Posted by unlucky [Vologda SPU] 3 Feb 2010 23:24
class Scanner {

   StreamTokenizer in;

   Scanner(InputStream stream) {
      in = new StreamTokenizer(new BufferedReader(new InputStreamReader(stream)));
   }

   void asserT(boolean e) {
      if (!e) {
         throw new Error();
      }
   }

   int nextInt() {
      try {
         in.nextToken();
         asserT(in.ttype == in.TT_NUMBER);
         asserT((int) in.nval == in.nval);
         return (int) in.nval;
      } catch (IOException e) {
         throw new Error(e);
      }
   }
}
".. and nothing else matters ..." (c)Metallica