Results 1 to 3 of 3
  1. #1
    Ace
    Ace is offline Member
    Join Date
    Nov 2011
    Location
    Earth
    Posts
    16
    Rep Power
    0

    Question Curious input form

    Hi
    I have the following input:

    n=6,m=9
    {0,1}1 {0,5}3 {1,2}9 {1,3}7 {1,5}5 {2,3}8 {3,4}5 {3,5}2 {4,5}4
    I want to cut from it only numbers, treating other characters as delimiters. I know, I can use the Scanner with useDelimiter("\\D+") method, but in that task the execution time is very important, and Scanner is not that fast on the test units (Pentium 700 MHz..., yeah, SPOJ computers). I'm thinking about StreamTokenizer, but I have no idea how to use delimiters here. How I can establish them... Or maybe you have some thoughts about other I/O classes? Tell me, I will be grateful!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Curious input form

    This can be easily solved with regular expressions, such as can be done via String#split(...), but I don't know if this will be a faster or slower solution, and suspect that it will be slower. Out of curiosity, why the severe speed requirement?

  3. #3
    Ace
    Ace is offline Member
    Join Date
    Nov 2011
    Location
    Earth
    Posts
    16
    Rep Power
    0

    Default Re: Curious input form

    Quote Originally Posted by Fubarable View Post
    Out of curiosity, why the severe speed requirement?
    Good question :d Sphere Online Judge (SPOJ) has a lot of tasks to solve, each of them has time limit for its execution, and their test units are Pentium 700 Mhz, well I need to optimize my programs. My current problem is to find Minimal Spanning Tree (I have solved it with the Kruskal's algorithm and the union-find structure) with time limit 10 seconds for Java and my record is 7 seconds when someone done it in no more than 2 seconds...
    Last edited by Ace; 04-22-2012 at 05:01 PM.

Similar Threads

  1. Accessing the Value of a Form File Input
    By shawngoldw in forum Java Applets
    Replies: 2
    Last Post: 04-15-2012, 04:59 AM
  2. Replies: 2
    Last Post: 01-25-2012, 11:41 AM
  3. how to retrieve data when i select the input from the form
    By sharanya in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 03-08-2011, 10:39 AM
  4. Create a form, input some data and save to file
    By cselic in forum AWT / Swing
    Replies: 5
    Last Post: 05-07-2010, 12:28 PM
  5. designing form to input into database
    By javahsm in forum New To Java
    Replies: 2
    Last Post: 11-29-2008, 10:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •