Results 1 to 3 of 3
Thread: Curious input form
- 04-22-2012, 10:26 AM #1
Member
- Join Date
- Nov 2011
- Location
- Earth
- Posts
- 16
- Rep Power
- 0
Curious input form
Hi
I have the following input:
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!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
-
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?
- 04-22-2012, 04:58 PM #3
Member
- Join Date
- Nov 2011
- Location
- Earth
- Posts
- 16
- Rep Power
- 0
Re: Curious input form
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
-
Accessing the Value of a Form File Input
By shawngoldw in forum Java AppletsReplies: 2Last Post: 04-15-2012, 04:59 AM -
How to take input from a form and then output a replace rule
By shaburnburn in forum New To JavaReplies: 2Last Post: 01-25-2012, 11:41 AM -
how to retrieve data when i select the input from the form
By sharanya in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 03-08-2011, 10:39 AM -
Create a form, input some data and save to file
By cselic in forum AWT / SwingReplies: 5Last Post: 05-07-2010, 12:28 PM -
designing form to input into database
By javahsm in forum New To JavaReplies: 2Last Post: 11-29-2008, 10:37 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks