Hi,
Sorry to post my code here, but I really have nothing else to do to get out of this annoying RTE<SIGSEGV>. Off course, I did grow my array size but I don't think it would help at all. Someone, please gimme a hint to get a WA...
[cpp]---CODE WAS CUT---[/cpp]
Thank's
Raysa
Last edited by raysa on Wed Apr 09, 2003 8:46 am, edited 1 time in total.
I thought so. I took the number of cases first before continue processing input. Is there anything wrong with my m_input handling in my code above? Can m_input cause an RTE?
Just found my mistake:
I used same array of char for the index and the elements. I've NULL-ed the array after inputting the index, but forgot doing so for the elements... It surely messed up the next inputs and cause an RTE. AC now...
Anyway, thank's for your help, Turuthok! Really apreciate it...
your code seems pretty wiered to me. i solved the problem in quite straight forward way. the process i followed is:
1. i made a structure array with an integer for index and a char array for the floating number.
2. i read first line and counted the number of input in that line and store them in the array as indices. suppose i got n inputs in the first line.
3. i then read n floating point number as string and store them in the array with theire indices.
4. i sorted the array according to the index value.
5. i printed all the stored floating point number.
thats it. i used qsort to sort the array. char array for float is important bcoz i need to print number exactly as the input.
hope it might help.
good luck
-sohel
saiqbal wrote:
following code might help:
[c]
typedef struct
{
int index;
char num[20];
} array;
array a[100000];
[/c]
good luck
-sohel
I am afraid this structure array's size still not big enough...
I just got AC by changing my arraysize
output[10000][20] --> output[10000][55]
So the judge input must have some number that is very very long and cause RTE.
just read another thread for this problem. size will not greater than 2000. be careful that there could be many spaces between numbers, so that each line could be more than 1000000 chars.
i think 20 characters per number is ok..
To solve this i took two input in string. Using sscanf i pick the int or float number. The float number is kept in a structure. Sort the float number than print it according to problem.
Are you know that this problem has multiple input!?
I know this, but have WA. Can somebody help me why it gets WA???
[pascal]
program acm482 (input, output);
const c = 1000000;
var ind: array [1..c] of integer;
zn: array [1..c] of string;
i, j, n, k: integer;
ch: char;
begin
{ assign(input, 'input.txt');
reset(input);
}
readln(k);
readln;
for j:=1 to k do begin
n:=0;
while not eoln do begin
inc(n);
read(ind[n]);
end;
readln;
for i:=1 to c do zn:='';
i:=0;
while i<>n do begin
read(ch);
if ch<>' ' then inc(i);
while (ch<>' ') and (ch<>#26) and (ch<>#13) do begin
zn[ind]:=zn[ind]+ch;
read(ch);
end;
end;
for i:=1 to n do
writeln(zn);
readln;
writeln;
end;
end.
[/pascal]