Page 3 of 4

Posted: Tue Jan 31, 2006 9:56 pm
by tan_Yui
The input will consist of an arbitrary number of input sets. Each input set begins with a positive integer n < 100, alone in a line, which describes the number of lines of the standard solution. The next n lines contain the standard solution. Then there is a positive integer m < 100, alone in a line, which describes the number of lines of the team output. The next m lines contain the team output. The input is terminated by a value of n = 0, and should not be processed. No line will have more than 120 characters.
http://online-judge.uva.es/p/v101/10188.html
This is the description. Is it right? :wink:

n and m are not described the mazimum length of each line.

Thank you.

Posted: Tue Jan 31, 2006 11:27 pm
by liangchene

Posted: Tue Jan 31, 2006 11:30 pm
by liangchene
However, I got accepted.

strange

Posted: Wed Feb 01, 2006 1:10 am
by tan_Yui
I didn't know this website.

I think that almost every solvers use this board to discuss about the problems of http://online-judge.uva.es/problemset/ .
And, the site "Programming Challenges" says "This site is still in beta testing and several features are not yet completely stable." on top page.

If you find some difference between two website, and have any doubts, it's better to tell the admin of "Programming Challenges".


By the way, I want to know what the meaning of this site is.
Is this site for training of programming?
Can I get these information if I made my account ....?

Posted: Wed Feb 22, 2006 7:06 am
by devious
Ok, so I have tried all the test samples for this problem that y'all have supplied....and everything comes out correctly. This means..either there is some off the wall test case I am not considering, or my I/O is totally screwed... can y'all trace through my code and find my mistake? I am tired of WA ... -.-

Code: Select all

Accepted

Posted: Wed Feb 22, 2006 8:54 am
by tan_Yui
Hi, devious.
There is an input data in my previous post of this thread.
Your code was failed on this input :
1

2


0
Output for this input is "Presentation Error".
Ok, so I have tried all the test samples for this problem that y'all have supplied....and everything comes out correctly. This means..either there is some off the wall test case I am not considering, or my I/O is totally screwed... can y'all trace through my code and find my mistake? I am tired of WA ... -.-
Sorry, I have no time to see your code now because of busy and not good at Java... :(
So, I simply checked to find critical input only....

Posted: Wed Feb 22, 2006 9:49 am
by devious
Thanks,
Lol, I flipped back to the first post, and realised the problem he was having was the problem I was having. I needed to include the newline characters. Got it accepted ;D

Posted: Mon May 14, 2007 5:16 am
by razor_blue
Why my code is wrong? Somebody help me, please? Give me some test case, that my program fails... :cry:

Code: Select all

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 13000

int main()
{
	int run=1,m,n,i,j,k;
	char ans[MAX],out[MAX],num[20],line[130],flag;
	while(gets(num))
	{
		n=atoi(num);
		if(!n) break;
		memset(ans,0,sizeof(ans));
		memset(out,0,sizeof(out));
		for(i=0;i<n;i++)
		{ gets(line); strcat(ans,line); }
		gets(num); m=atoi(num);
		for(i=0;i<m;i++)
		{ gets(line); strcat(out,line); }
		if(!strcmp(ans,out)&&m==n) flag=1;
		else
		{
			for(i=j=0;ans[i]&&out[j];i++)
				if(ans[i]>='0'&&ans[i]<='9')
				{
					while(out[j]&&(out[j]<'0'||out[j]>'9')) j++;
					if(ans[i]!=out[j]) { flag=-1; goto zap; }
					j++;
				}
			flag=0;
		}
		zap:
		printf("Run #%d: ",run++);
		if(flag>0) printf("Accepted\n");
		else if(flag==0) printf("Presentation Error\n");
		else printf("Wrong Answer\n");
	}
	return 0;	
}

Posted: Mon Nov 05, 2007 9:28 pm
by Fuad Hassan EWU
I am getting WA continuously.....

Code: Select all

AC

Posted: Mon Nov 05, 2007 11:01 pm
by A1
Fuad Hassan EWU wrote:I am getting WA continuously.....
Try these inputs:

Code: Select all

3
123
123
123
1
123123123

1
123
2
1
23

2
123
123
1
12312

1
12
1
123

1
123
1
12

0

Output should be:

Code: Select all

Run #1: Presentation Error
Run #2: Presentation Error
Run #3: Wrong Answer
Run #4: Wrong Answer
Run #5: Wrong Answer

Posted: Tue Nov 06, 2007 2:26 pm
by Fuad Hassan EWU
thanks A1 brothers. now i am successfully done.
all i should have considered is consider all the standard solution as one input and team respnse as one input. then do the simple calculation. :lol:

RE

Posted: Wed Feb 13, 2008 10:02 am
by Clock2008
I keep getting Runtime Error, could somebody tell me why?
this is my code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int in,out,i,j,flag,p,q,count=1;
char input[200][200],output[200][200],a[200],b[200],h;
while(scanf("%d",&in)!=EOF){
if(in==0)
break;
h=getchar();
for(i=0;i<200;i++){
a='a';
b='a';
}
p=0;
for(i=0;i<in;i++){
fgets(input,200,stdin);
for(j=0;j<strlen(input);j++){
if(input[j]<='9' && input[j]>='0'){
a[p]=input[j];
p++;
}
}
}
q=0;
scanf("%d",&out);
h=getchar();
for(i=0;i<out;i++){
fgets(output,200,stdin);
for(j=0;j<strlen(output);j++){
if(output[j]<='9' && output[i][j]>='0'){
b[q]=output[i][j];
q++;
}
}
}
flag=0;
for(i=0;i<in;i++){
if(strcmp(input[i],output[i])!=0){
flag=1;
if(strcmp(a,b)!=0)
printf("Run #%d: Wrong Answer\n",count);
else
printf("Run #%d: Presentation Error\n",count);
break;
}
}
if(flag==0)
printf("Run #%d: Accepted\n",count);
count++;
}
return 0;
}

I don't know why this program get RE... plz check this code

Posted: Wed Nov 05, 2008 11:11 am
by bongssi

Code: Select all

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void){

   char answer[81*50], submit[81*50], line[50], answer_num[81*50], submit_num[81*50];
   int runs, answer_lines, submit_lines, answer_len, submit_len, num_match, str_match;
   int i, j;

   runs = 1;
   while(1){
      scanf("%d", &answer_lines);
      getchar();
      if(answer_lines == 0) break;
      for(i=0; i<answer_lines; i++){
         gets(line);
         strcat(answer, line);
      }

      scanf("%d", &submit_lines);
      getchar();
      if(submit_lines == 0) break;
      for(i=0; i<submit_lines; i++){
         gets(line);
         strcat(submit, line);
      }

      answer_len = strlen(answer);
      submit_len = strlen(submit);

      for(i=0, j=0; i<answer_len; i++)
         if(isdigit(answer[i])) answer_num[j++] = answer[i];
      answer_num[j] = '\0';

      for(i=0, j=0; i<submit_len; i++)
         if(isdigit(submit[i])) submit_num[j++] = submit[i];
      submit_num[j] = '\0';

      num_match = 0;
      str_match = 0;
      if(strcmp(answer_num, submit_num) == 0){
         num_match = 1;
         if(strcmp(answer, submit) == 0) str_match = 1;
      }
      printf("Run #%d: ", runs);
      if(num_match == 0) printf("Wrong Answer\n");
      else{
         if(str_match == 0) printf("Presentation Error\n");
         else printf("Accepted\n");
      }
      runs++;
      answer[0] = '\0';
      submit[0] = '\0';
      answer_num[0] = '\0';
      submit_num[0] = '\0';
   }
   return 0;
}

10188 - Automated Judge Script

Posted: Sun Jan 11, 2009 11:16 pm
by alirezanoori
Well, in here its 00:40 midnight :D
I coded the problem and got AC on first try. The inputs are not so huge so here's a simple algorithm. Hope it helps.

get n and get n lines onto CORRECT answer
get m and get m lines onto INPUT strings

if(n == m) it means sizes are equal so there is a probability for AC. so
inside a loop check if every string of INPUT is exactly equal to corresponding CORRECT answer set. if so, return AC.
else
get two another strings. For each of these sets (CORRECT and INPUT) just push the numbers onto these strings then compare them. if they are equal, return PE.
else
return WA.

I used std::string for my c++ program and used the += and == operators.
Just like that.
;)

As for the previous post, the first thing I noticed is that your program does not initialize the arrays so just move the last lines after the while loop. Like this:

Code: Select all

while(1){
          answer[0] = submit[0] = answer_num[0] = submit_num[0] = '\0';
          //....
But after this, you'll get RE too. But why? Because each line is 120 chars at max, Not 50. So just change the first line of your code to:

Code: Select all

char answer[81*122], submit[81*122], line[122], answer_num[81*122], submit_num[81*122];
AAAH, you forgot something else. Each input can be 100 lines, not 81 lines. So that should be:

Code: Select all

char answer[101*122], submit[101*122], line[122], answer_num[101*122], submit_num[101*122];
Note that just for safety I used 101 and 122instead of 100 and 100. But after this, you'll get WA.

Also I suggest you to use dynamic arrays for these types of arrays (with huge sizes). Like this:

Code: Select all

char line[122];
	char *answer = (char*)malloc(101*122);
	char *submit = (char*)malloc(101*122);
	char *answer_num = (char*)malloc(101*122);
	char *submit_num = (char*)malloc(101*122);
//...
	free(answer);
	free(submit);
	free(answer_num);
	free(submit_num);
So what about the WA? After trying this input you'll get the idea:

Code: Select all

3
123
123
123
1
123123123
0

//output
Run #1: Presentation Error
But your program accepts it. Because you don't include the new line characters. So just use something like this:

Code: Select all

                for(i=0; i<answer_lines; i++){
			gets(line);
			strcat(answer, " "); //add space instead of new line
			strcat(answer, line);
		}
You should use this for input of submit array too.
Hope it helps.
I didn't test the program but I think it should get AC.

Re: 10188 - Automated Judge Script

Posted: Mon Mar 02, 2009 5:35 pm
by vahid sanei
these kind of problems just waste time :x
i used vector<string>
but Judge dont check ' \n ' in inputs , "all of them are just one string"
it was better if judge checked '\n'