# FAQ for problem setters

For the past few weeks we have been getting questions from people interested in setting problems for our contests. Here is a quick FAQ as to what you need to do before sending us the problems and if/how your problems will be used in our contests. Now, at present, we have 2 types of problems in our contest. The first category is the exact algorithm contest problems which have either a wrong or a correct answer. The other type is the challenge problem that we have in each contest.

This problem is such that it does not have a deterministic solution. Which means that there is no algorithm that will give an optimal answer for the problem. Submitting problems for both these categories is slightly different.

Exact Algorithm Problems :

Q. What kind of problems are you looking for in the Exact Algorithm Problems category?

A. We are looking for problems which are not standard ones or ones which are not easily ‘googleable’. The problem should be such that it induces the solver to spend time to think of a solution to the problem rather than search for it online.

Q. What files do I need to submit along with the problem?

A. You need to submit the following files :
1) The problem story line. This is the main body of the problem that the participant will read. This should not be ambiguous and should be clear and interesting. It should specify the input format, the output format as well as the constraints on the input and if any, on the output.
2) The solution in a programming language of your choice. This solution should be such that it takes in the input data in the specified format and produces the correct output according to the output format.
3) The test input data. This input data should have all the corner cases covered and should have a few randomly generated test cases too. If there are multiple input files, label them as 0.in, 1.in, 2.in and so on and place all of them in a folder called ‘input’.
4) The output test data. This is the output data corresponding to the input data mentioned previously. The expected output for 0.in should be placed in 0.out, for 1.in should be in 1.out and so on. Place all these files in a folder called ‘output’.
5) A small write-up of the approach taken. You need to give us a small write-up about the approach taken to solve the problem.

Q. How do I send you all the files?

A. Place all the files and folders in another folder named whatever you wish to call the problem. Archive it using an archiver, preferably in .zip or .tar.gz format. Send this archived file as an attachment along with your contact information to admin@codechef.com

Q. How many problems can I submit?

A. You can submit as many problems as you like. If we like a problem, we will use it in one of our contests. If we decide to use your problem in our contest, you would not be eligible to participate in that month’s contest. You might want to send us a set of 4-5 problems so that we might use a higher number of problems in the same contest.

Q. How much do I get paid for submitting the problem?
A. There is no payment for submitting a problem. However, if we decide to use your problem in our contest, we will compensate you accordingly. The compensation would depend on the quality of problems you have submitted. An easy problem would have less compensation compared to a hard one.

Challenge Problems :

There are a couple of things different for challenge problems.

Q. What kind of problems are you looking for in the Challenge Problem category?

A. We are again looking for problems which are not very highly researched. The approaches for such problems should not be available online easily. The problems should not have a polynomial time solution. The challenge problem has a scoring mechanism based on certain parameters. This scoring mechanism needs to be explained properly in the problem statement submitted by you. Also, you need to specify whether the optimal solution minimizes this score or maximizes this score.

Q. What files do I need to submit along with the problem?

A. You need to submit the following files :
1) The problem story line. This is the same as the earlier category. Along with the constraints and other things, you need to mention how the problem is scored and also whether the optimal approach should maximize or minimize the score.
2) The input test data. This should have random and large test cases. Place all the input files in a folder called ‘input’.
3) A program in a programming language of your choice that reads the output and returns the score for that output based on the scoring parameters.
4) A write-up specifying why the problem does not have a polynomial time solution. Some links or research papers pointing to this would be appreciated.

## A Behind The Scenes With Contest Admin Alei Reyes!

For a while now Alei Reyes has been the contest admin for the CodeChef Long Challenges. The 7-star coder has been key to the...  alei

## A Behind-The-Scenes With Contest Admin Alei Reyes

For a while now Alei Reyes has been the contest admin for the CodeChef Long Challenges. The 7-star coder has been key to the... riddhi_225

## Update in Problem Setting Guidelines

Hola Amigos, We are delighted that we turned Senary this March. All this would not have been possible without  the problem setting panel in...  surajmsharma

## 3 Replies to “FAQ for problem setters”

1. Manish C says:

hi, My programming is not so strong so i m posting some questions of C & C++ so please mail me the solutions at the earliestC,C++ Questions1. Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived object,. calling of that virtual method will result in which method being called? a. Base method b. Derived method..2. For the following C program#define AREA(x)(3.14*x*x)main(){float r1=6.25,r2=2.5,a;a=AREA(r1);printf(“n Area of the circle is %f”, a);a=AREA(r2);printf(“n Area of the circle is %f”, a);}What is the output?3. What do the following statements indicate. Explain. • int(*p) • int*f() • int(*pf)() • int*p 4.void main(){int d=5;printf(“%f”,d);}5. void main(){int i;for(i=1;i k=255; */signed j=-1; /* char k= -1 => k=65535 *//* unsigned or signed int k= -1 =>k=65535 */if(ij)printf(“greater”);elseif(i==j)printf(“equal”);}8.void main(){float j;j=1000*1000;printf(“%f”,j);}1. 10000002. Overflow3. Error4. None 9. How do you declare an array of N pointers to functions returning pointers to functions returning pointers to characters?10. A structure pointer is defined of the type time . With 3 fields min,sec hours having pointers to intergers. Write the way to initialize the 2nd element to 10.11. In the above question an array of pointers is declared. Write the statement to initialize the 3rd element of the 2 element to 10;12.int f()void main(){f(1);f(1,2);f(1,2,3);}f(int i,int j,int k){printf(“%d %d %d”,i,j,k);}What are the number of syntax errors in the above? 13. void main(){int i=7;printf(“%d”,i++*i++);} 14. #define one 0#ifdef one printf(“one is defined “);#ifndef oneprintf(“one is not defined “); 15.void main(){int count=10,*temp,sum=0;temp=&count;*temp=20;temp=∑*temp=count;printf(“%d %d %d “,count,*temp,sum);} 16. There was question in c working only on unix machine with pattern matching.14. what is alloca()17. main(){static i=3;printf(“%d”,i–);return i>0 ? main():0;} 18. char *foo(){char result);strcpy(result,”anything is good”);return(result);}void main(){char *j;j=foo()printf(“%s”,j);}19.void main(){char *s[]={ “dharma”,”hewlett-packard”,”siemens”,”ibm”};char **p;p=s;printf(“%s”,++*p);printf(“%s”,*p++);printf(“%s”,++*p);}20. Output of the following program ismain(){int i=0;for(i=0;ii){printf(“pass1,”);if(c<u)printf(“pass2”);elseprintf(“Fail2”);}elseprintf(“Fail1);if(i<u)printf(“pass2”);elseprintf(“Fail2″)}a) Pass1,Pass2b) Pass1,Fail2c) Fail1,Pass2d) Fail1,Fail2e) None of these22. What will the following program do?void main(){int i;char a[]=”String”;char *p=”New Sring”;char *Temp;Temp=a;a=malloc(strlen(p) + 1);strcpy(a,p); //Line number:9//p = malloc(strlen(Temp) + 1);strcpy(p,Temp);printf(“(%s, %s)”,a,p);free(p);free(a);} //Line number 15//a) Swap contents of p & a and print:(New string, string)b) Generate compilation error in line number 8c) Generate compilation error in line number 5d) Generate compilation error in line number 7e) Generate compilation error in line number 123. In the following code segment what will be the result of the function, value of x , value of y{unsigned int x=-1;int y;y = ~0;if(x == y)printf(“same”);elseprintf(“not same”);}a) same, MAXINT, -1b) not same, MAXINT, -MAXINTc) same , MAXUNIT, -1d) same, MAXUNIT, MAXUNITe) not same, MAXINT, MAXUNIT24. What will be the result of the following program ?char *gxxx(){static char xxx;return xxx;}main(){char *g=”string”;strcpy(gxxx(),g);g = gxxx();strcpy(g,”oldstring”);printf(“The string is : %s”,gxxx());}a) The string is : stringb) The string is :Oldstringc) Run time error/Core dumpd) Syntax error during compilatione) None of these25. Find the output for the following C program main(){char *p1=”Name”;char *p2;p2=(char *)malloc(20);while(*p2++=*p1++);printf(“%sn”,p2);}26. Find the output for the following C programmain(){int x=20,y=35;x = y++ + x++;y = ++y + ++x;printf(“%d %dn”,x,y);}27. Find the output for the following C programmain(){int x=5;printf(“%d %d %dn”,x,x<>2);}28 Find the output for the following C program#define swap1(a,b) a=a+b;b=a-b;a=a-b;main(){int x=5,y=10;swap1(x,y);printf(“%d %dn”,x,y);swap2(x,y);printf(“%d %dn”,x,y);}int swap2(int a,int b){int temp;temp=a;b=a;a=temp;return;}29 Find the output for the following C programmain(){char *ptr = “Ramco Systems”;(*ptr)++;printf(“%sn”,ptr);ptr++;printf(“%sn”,ptr);}30 Find the output for the following C program#includemain(){char s1[]=”Ramco”;char s2[]=”Systems”;s1=s2;printf(“%s”,s1);}31 Find the output for the following C program#includemain(){char *p1;char *p2;p1=(char *) malloc(25);p2=(char *) malloc(25);strcpy(p1,”Ramco”);strcpy(p2,”Systems”);strcat(p1,p2);printf(“%s”,p1);}32. Find the output for the following C program given that. The following variable is available in file1.cstatic int average_float;33. Find the output for the following C program# define TRUE 0some codewhile(TRUE){some code }34. struct list{ int x; struct list *next; }*head; the struct head.x =100 Is the above assignment to pointer is correct or wrong ?35.What is the output of the following ? int i; i=1; i=i+2*i++; printf(%d,i);36. FILE *fp1,*fp2; fp1=fopen(“one”,”w”) fp2=fopen(“one”,”w”) fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2) } Find the Error, If Any?37. What are the output(s) for the following ?38. #include char *f() {char *s=malloc(8); strcpy(s,”goodbye”); } main() { char *f(); printf(“%c”,*f()='A'); }39. #define MAN(x,y) (x)>(y)?(x):(y) {int i=10; j=5; k=0; k=MAX(i++,++j); printf(%d %d %d %d,i,j,k); }40. void main(){int i=7;printf(“%d”,i++*i++);}

2. Manish C says:

hi,
My programming is not so strong so i m posting some questions of C & C++ so please mail me the solutions at the earliest
C,C++ Questions
1. Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived
object,. calling of that virtual method will result in which method being called?
a. Base method
b. Derived method..
2. For the following C program
#define AREA(x)(3.14*x*x)
main()
{float r1=6.25,r2=2.5,a;
a=AREA(r1);
printf(“n Area of the circle is %f”, a);
a=AREA(r2);
printf(“n Area of the circle is %f”, a);
}
What is the output?
3. What do the following statements indicate. Explain.
• int(*p)
• int*f()
• int(*pf)()
• int*p
4.
void main()
{
int d=5;
printf(“%f”,d);
}
5.
void main()
{
int i;
for(i=1;i k=255; */
signed j=-1; /* char k= -1 => k=65535 */
/* unsigned or signed int k= -1 =>k=65535 */
if(ij)
printf(“greater”);
else
if(i==j)
printf(“equal”);
}
8.
void main()
{
float j;
j=1000*1000;
printf(“%f”,j);
}

1. 1000000
2. Overflow
3. Error
4. None
9. How do you declare an array of N pointers to functions returning
pointers to functions returning pointers to characters?

10. A structure pointer is defined of the type time . With 3 fields min,sec hours having pointers to intergers.
Write the way to initialize the 2nd element to 10.

11. In the above question an array of pointers is declared.
Write the statement to initialize the 3rd element of the 2 element to 10;

12.
int f()
void main()
{
f(1);
f(1,2);
f(1,2,3);
}
f(int i,int j,int k)
{
printf(“%d %d %d”,i,j,k);
}

What are the number of syntax errors in the above?

13.
void main()
{
int i=7;
printf(“%d”,i++*i++);
}

14.
#define one 0
#ifdef one
printf(“one is defined “);
#ifndef one
printf(“one is not defined “);

15.
void main()
{
int count=10,*temp,sum=0;
temp=&count;
*temp=20;
temp=∑
*temp=count;
printf(“%d %d %d “,count,*temp,sum);
}

16. There was question in c working only on unix machine with pattern matching.

14. what is alloca()
17.
main()
{
static i=3;
printf(“%d”,i–);
return i>0 ? main():0;
}

18.
char *foo()
{
char result);
strcpy(result,”anything is good”);
return(result);
}
void main()
{
char *j;
j=foo()
printf(“%s”,j);
}

19.
void main()
{
char *s[]={ “dharma”,”hewlett-packard”,”siemens”,”ibm”};
char **p;
p=s;
printf(“%s”,++*p);
printf(“%s”,*p++);
printf(“%s”,++*p);
}
20. Output of the following program is
main()
{int i=0;
for(i=0;ii)
{printf(“pass1,”);
if(c<u)
printf(“pass2”);
else
printf(“Fail2”);
}
else
printf(“Fail1);
if(i<u)
printf(“pass2”);
else
printf(“Fail2”)
}
a) Pass1,Pass2
b) Pass1,Fail2
c) Fail1,Pass2
d) Fail1,Fail2
e) None of these
22. What will the following program do?
void main()
{
int i;
char a[]=”String”;
char *p=”New Sring”;
char *Temp;
Temp=a;
a=malloc(strlen(p) + 1);
strcpy(a,p); //Line number:9//
p = malloc(strlen(Temp) + 1);
strcpy(p,Temp);
printf(“(%s, %s)”,a,p);
free(p);
free(a);
} //Line number 15//
a) Swap contents of p & a and print:(New string, string)
b) Generate compilation error in line number 8
c) Generate compilation error in line number 5
d) Generate compilation error in line number 7
e) Generate compilation error in line number 1
23. In the following code segment what will be the result of the function,
value of x , value of y
{unsigned int x=-1;
int y;
y = ~0;
if(x == y)
printf(“same”);
else
printf(“not same”);
}
a) same, MAXINT, -1
b) not same, MAXINT, -MAXINT
c) same , MAXUNIT, -1
d) same, MAXUNIT, MAXUNIT
e) not same, MAXINT, MAXUNIT
24. What will be the result of the following program ?
char *gxxx()
{static char xxx;
return xxx;
}
main()
{char *g=”string”;
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,”oldstring”);
printf(“The string is : %s”,gxxx());
}
a) The string is : string
b) The string is :Oldstring
c) Run time error/Core dump
d) Syntax error during compilation
e) None of these
25. Find the output for the following C program
main()
{
char *p1=”Name”;
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf(“%sn”,p2);
}
26. Find the output for the following C program
main()
{
int x=20,y=35;
x = y++ + x++;
y = ++y + ++x;
printf(“%d %dn”,x,y);
}
27. Find the output for the following C program
main()
{
int x=5;
printf(“%d %d %dn”,x,x<>2);
}
28 Find the output for the following C program
#define swap1(a,b) a=a+b;b=a-b;a=a-b;
main()
{
int x=5,y=10;
swap1(x,y);
printf(“%d %dn”,x,y);
swap2(x,y);
printf(“%d %dn”,x,y);
}
int swap2(int a,int b)
{
int temp;
temp=a;
b=a;
a=temp;
return;
}
29 Find the output for the following C program
main()
{
char *ptr = “Ramco Systems”;
(*ptr)++;
printf(“%sn”,ptr);
ptr++;
printf(“%sn”,ptr);
}
30 Find the output for the following C program
#include
main()
{
char s1[]=”Ramco”;
char s2[]=”Systems”;
s1=s2;
printf(“%s”,s1);
}
31 Find the output for the following C program
#include
main()
{
char *p1;
char *p2;
p1=(char *) malloc(25);
p2=(char *) malloc(25);
strcpy(p1,”Ramco”);
strcpy(p2,”Systems”);
strcat(p1,p2);
printf(“%s”,p1);
}
32. Find the output for the following C program given that
. The following variable is available in file1.c
static int average_float;
33. Find the output for the following C program
# define TRUE 0
some code
while(TRUE)
{
some code
}
34. struct list{
int x;
struct list *next;

Is the above assignment to pointer is correct or wrong ?
35.What is the output of the following ?

int i;
i=1;
i=i+2*i++;
printf(%d,i);
36. FILE *fp1,*fp2;

fp1=fopen(“one”,”w”)
fp2=fopen(“one”,”w”)
fputc('A',fp1)
fputc('B',fp2)
fclose(fp1)
fclose(fp2)
}

Find the Error, If Any?
37. What are the output(s) for the following ?
38. #include
char *f()
{char *s=malloc(8);
strcpy(s,”goodbye”);
}

main()
{
char *f();
printf(“%c”,*f()='A'); }

39. #define MAN(x,y) (x)>(y)?(x):(y)
{int i=10;
j=5;
k=0;
k=MAX(i++,++j);
printf(%d %d %d %d,i,j,k);
}
40.
void main()
{
int i=7;
printf(“%d”,i++*i++);
}

3. hunterx1337 says: