Page 3 of 6

481-I/O needed

Posted: Thu Mar 30, 2006 11:41 pm
by serur
some test cases for 481- What goes up, please.
this nasty WA...

481-What Goes Up

Posted: Fri Mar 31, 2006 12:21 am
by serur


Posted: Fri Mar 31, 2006 10:27 am
by serur
OK, in the long run I got it accepted!
If you need for Output you should feel free to ask me...
I'm grateful to Stephanus Indra & Steven Halim for their explanation of LIS algorithm on their website.
and another related 497-"Defence" AC! :D

Posted: Mon Apr 10, 2006 12:40 am
by Moha
For each element you can store its papa. and tracing back all the papa to read null, would results in sequence. Think about it, you can figure it.

Posted: Sun Apr 16, 2006 6:40 am
by DasBoot
I keep getting WA.
Can someone post some test cases for this?
I went through all the posts, and my program gives the correct answer for everything discussed so far.

This problem is driving me crazy.

Posted: Sun Apr 16, 2006 9:17 am
by Moha
Try this:
I got this sample from adrian.

481 - About arrays...

Posted: Wed May 24, 2006 7:38 pm
by Quake2
Hi! I just solved problem 481 and I'm fifth, but I was wondering if my solution was fair, since I've used big arrays for almost anything (and used crazy I/O routines, something that usually I don't use for normal I/O operations), since most of the time was taken during I/O (e.g. I did some timing with rdtsc (reads the internal time stamp counter), my LIS algorithm ran in about 20 million cycles (using an input file of 50000 numbers), my first version of the I/O routines in about 60 milion cycles (both for input and output), solving this and others problems, makes me wonder if we are challenged to write fast I/O routines or fast algorithms, I know that with today hardware memory is not an issue, but keep in mind that on some(old) architectures there is still the 4gb limit, I think that problems sholud have a well defined number of test cases, e.g. the first line of problem 481 should be the total number of numbers to read, this way memory usage could be reduced a lot
anyway, I noticed that this was an issue with older problems, most of the modern ones are well defined
let me know what you think...

Posted: Tue Jun 06, 2006 12:25 pm
by feanor
i think that problem 481 could be done using a "one-pass" algorithm. so you can read the numbers in input one-by-one without put them into an array! 8) take a look at this ... TR-931.pdf ...
i've implemented the algorithm described in this article but the judge give me compile error! even i've tried my implementation with huge input! can you give some I/O? or can you take a look to my code??

481 What goes up --- help!

Posted: Thu Jul 20, 2006 3:02 am
by IRA
When I read the LIS algorithm which time complexity is O(nlogn).
But that only know the longest length value,doesn't know the real increase subsequence content.
How could I do to find the correct subsequence in this algorithm?
Who can show me some opinion?
This is my reference as fallow....... ... _(LIS/LDS)
Thanks in advance!

Q481 - How to input ?

Posted: Fri Aug 04, 2006 3:33 pm
by chensc
Umm...I know this problem should be solved by LIS.
But I don't know how to input.
Fllowing is my code , would you give me any suggestion?
It've got RE for so many times.

Code: Select all

Removed After TLE...XD

Posted: Fri Aug 04, 2006 6:45 pm
by Darko
I just checked my code and my MAX is 200010.

Posted: Sat Aug 05, 2006 9:32 am
by Wei-Ming Chen
max = 100000 is enough

Posted: Sat Aug 05, 2006 3:46 pm
by chensc
Umm...Thank you.
But after the array=100000, It became to get TLE.
Fllowing is my new code, could you give me a hand?
That's very kind of you. :)

Code: Select all

#include <stdio.h>
#define MAX 100000

int main(){
	register short num[MAX];
	register short length[MAX]={0};
	register short lis[MAX];
	register unsigned short index=0;

	register unsigned short max=1,max_index=0;
	for(register unsigned short i=0; i<index; i++){
		register unsigned short tmp=0;
		for(register unsigned short j=0; j<i; j++)
			if(num[j]>num[i] && length[j]>tmp)
			max=length[i], max_index=i;

	for(register unsigned short i=max-1, j=max_index-1; i>0; j--)
		if(num[j]<num[max_index] && length[j]==i)
			lis[i--]=num[j], max_index=j;

	for(register unsigned short i=0; i<=max; i++)
	return 0;

Re: 481 What goes up --- help!

Posted: Mon Aug 07, 2006 1:52 am
by daveon
IRA wrote:But that only know the longest length value,doesn't know the real increase subsequence content.
Doesn't the predecessor array keep track of this for you?


Posted: Sun Dec 03, 2006 4:27 pm
by nymo
Hi, I 've used an INT array of size 50000 and getting WA. Can someone provide some IOs? [I 've tried IOs posted on other threads]... THANKS. and THERE IS ONLY ONE TEST CASE, RIGHT?