Page 3 of 11
Posted: Sun Feb 08, 2004 5:23 am
by shamim
Your code is difficult to follow because you have used no allignment.
Please submit your code with proper allignment.
Posted: Tue Feb 10, 2004 1:27 pm
by mohiul alam prince
shamim i have modify my source code
please chake it
prince
Not specified
Posted: Sat Feb 14, 2004 6:26 pm
by Mahmud776
I took 50010 for the size of the array for the first line . And the highest value for the first line of the input would be 1000.
I got accepted by using these size.
Not specified
Posted: Sat Feb 14, 2004 6:40 pm
by Mahmud776
You have to be more carefull about every things.This is a
multiple input(blue tick) problem.So, you have to process inputs in this way.
For your convenience in understanding this problem I gave some sample inputs and outputs.
Inputs:
2
4 1 5 2 3
-.000045 -0.00045 .456 .056987 25.26589456987
1 3 5 6 4 2
.004 .001 0.000007 0.23 -.0007 -56
Output:
-0.00045
.056987
25.26589456987
-.000045
.456
.004
-56
.001
-.0007
0.000007
0.23
why compile error 482
Posted: Sun Mar 07, 2004 8:08 pm
by Salmin Sultana
why compile error?
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
long int a[1000];
char array[1000][20];
char str[1000],s[100];
long int in,i,num,n,j,len,k;
double p;
scanf("%ld",&n);
fflush(stdin);
for(k=0;k<n;k++){
in=0;
gets(str);
len=strlen(str);
for(i=0;i<len;){
while(str==' ')
i++;
sscanf(&str,"%s",s);
i=i+strlen(s)+1;
a[in]=atol(s);
in++;
}
gets(str);
len=strlen(str);
for(i=0,j=0;j<in&&i<len;j++){
while(str==' ')
i++;
sscanf(&str,"%s",s);
i=i+strlen(s)+1;
num=a[j]-1;
strcpy(array[num],s);
}
for(i=0;i<in;i++)
printf("%s\n",array);
}
return 0;
}
Posted: Mon Mar 08, 2004 8:22 am
by sidky
I just submitted your code with the language C++, and it didn't produce any compile error. Please recheck your submission method.
why compile error 482
Posted: Mon Mar 08, 2004 4:15 pm
by Salmin Sultana
why compile error?
is my algorithm correct?
[cpp]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
long int a[1000000];
char array[1000000][1000];
char str[1000000],s[1000];
long int in,i,num,n,j,len,k;
double p;
scanf("%ld",&n);
fflush(stdin);
for(k=0;k<n;k++){
in=0;
gets(str);
len=strlen(str);
for(i=0;i<len;){
while(str==' ')
i++;
sscanf(&str,"%s",s);
i=i+strlen(s)+1;
a[in]=atol(s);
in++;
}
gets(str);
len=strlen(str);
for(i=0,j=0;j<in&&i<len;j++){
while(str==' ')
i++;
sscanf(&str,"%s",s);
i=i+strlen(s)+1;
num=a[j]-1;
strcpy(array[num],s);
}
for(i=0;i<in;i++)
printf("%s\n",array);
}
return 0;
}[/cpp]
Posted: Mon Mar 08, 2004 4:58 pm
by shamim
I compiled your code using Cygwin, and there was no compile error.
However, you have declared large inside your main function; so even if your code had compiled, it would receive run time error.
Posted: Tue Mar 09, 2004 11:36 am
by Salmin Sultana
it's a multiple input problem.i think i can't manage multiple input
problem.please tell what should be code change to provide multiple
input correctly.i took array outside main function but got wa.
Posted: Tue Mar 09, 2004 1:06 pm
by shamim
One thing i have noticed from your code is, you are first taking all the input and then giving all the output. For this, you are required to declare large arrays.
Simply take input for one set, process it, and give output. Then move on to take more input till the last case.
Posted: Tue Mar 09, 2004 2:48 pm
by alu_mathics
Multiple inputs are of the following form
Example:
3
100
1011
11231
3990
34
313
43
----
test case number.
blankline
block of input1
blank line
block of input2
blank line
block of input3
you can read this as:
gets(str);
test=atol(str);//sscanf(str,"%d",&test);
gets(str);
while(test--)
{
while(gets(str)&&str[0])
{
//here u can modify str as required
}
if(test)printf("\n");
}
Posted: Sat Oct 02, 2004 2:43 pm
by Hedge
Hello.
I am trying to solve the problem too, but i cant get it accepted.
Are there any tricky inputs? My programm can handle following input correctly:
Input:
Output:
The length of my input line is 50000 and i handle up to 2048 different numbers.
482 - Permutation Arrays
Posted: Mon Nov 01, 2004 3:31 pm
by Hedge
Hello,
i have some problems with
482. Acually it seems not very hard, but the lack of given sizes makes it a bit trickier.
What i am doing to try to solve it:
First i read every indices and store them in an array. Then i read the next line and parse every number and remember
each start position in a second array. I dont save them at secondArray[ i ] but at secondArray[ firstArray[ i ] -1 ],
so i do some kind of bucket sort right by reading. This seems to work quite fine for my own test cases.
Finally i just output every 'String' in the second array from 0 to the number of inputs.
I am quite aware that this is a multiple input problem and i think i handle it correctly, but i get WA all the time.
So my questions: How long can an input line be? I tried several hight figueres and am sticking with 50000.
How much numbers can be in one input line? I am taking 2048 but even much higher values get me WA.
What should i do with inputs like:
Is this:
or
Is there any case, my Algorithm is wrong?
Input:
Output:
I hope anyone can give me a slight hint, where I am wrong.
Posted: Mon Nov 01, 2004 7:24 pm
by Junayeed
I got AC with array size of 1000000.
Try with this.
Posted: Thu Nov 04, 2004 10:47 am
by Hedge
Unfortunately i had no luck, even with your high number.
Has anyone mean test cases?