题意:写一个judge脚本,判断WA,PE,AC;
算法:简单模拟;
连接:点击打开链接
#include <stdio.h>
#include <string.h>
#define MAX 105
void judge ( char answer[MAX][MAX], char test[MAX][MAX], const int n, const int m )
{
int i, j, k = 0, g = 0;
if ( n == m )
{
bool flag = true;
for ( i = 0; i < n; i++ )
if ( strcmp ( answer[i], test[i] ) )
{
flag = false;
break;
}
if ( flag )
{
puts ( "Accepted" );
return ;
}
}
char str[MAX*MAX], ch[MAX*MAX];
for ( i = 0; i < n; i++ )
{
int len = strlen ( answer[i] );
for ( j = 0; j < len; j++ )
if ( '0' <= answer[i][j] && answer[i][j] <= '9' )
str[k++] = answer[i][j];
}
str[k] = 0;
for ( i = 0; i < m; i++ )
{
int len = strlen ( test[i] );
for ( j = 0; j < len; j++ )
if ( '0' <= test[i][j] && test[i][j] <= '9' )
ch[g++] = test[i][j];
}
ch[g] = 0;
if ( !strcmp ( ch, str ) )
{
puts ( "Presentation Error" );
return ;
}
puts ( "Wrong Answer" );
}
int main ( )
{
int n, m, t = 1;
while ( ~scanf ( "%d", &n ) && n )
{
getchar ( );
char answer[MAX][MAX], test[MAX][MAX];
for ( int i = 0; i < n; i++ )
gets ( answer[i] );
scanf ( "%d", &m );
getchar ( );
for ( int j = 0; j < m; j++ )
gets ( test[j] );
printf ( "Run #%d: ", t++ );
judge ( answer, test, n, m);
}
return 0;
}