UVa 10188 Automated Judge Script

UVa 10188 Automated Judge Script

ACM的题目意思表达得真是隐晦~注意数字字符即使不在同一行也有可能顺序完全一致。
以下是我的代码:

#include < iostream >
#include
< string >
#define  maxn 107
using   namespace  std;

long  X,n,m;
string  a[maxn],b[maxn],da,db;

bool  Accepted()
{
    
if (n != m)  return   false ;
    
for ( long  i = 1 ;i <= n;i ++ )
      
if (a[i] != b[i])
        
return   false ;
    
return   true ;
}

bool  Presentation()
{
    da.clear();
    db.clear();
    
for ( long  i = 1 ;i <= n;i ++ )
      
for ( long  j = 0 ;j < ( long )a[i].length();j ++ )
        
if (a[i][j] >= ' 0 ' && a[i][j] <= ' 9 ' )
          da
+= a[i][j];
    
for ( long  i = 1 ;i <= m;i ++ )
      
for ( long  j = 0 ;j < ( long )b[i].length();j ++ )
        
if (b[i][j] >= ' 0 ' && b[i][j] <= ' 9 ' )
          db
+= b[i][j];
    
if (da != db)
      
return   false ;
    
return   true ;
}

long  judge()
{
    
if (Accepted())  return   1 ;
    
    
if (Presentation())  return   2 ;
    
    
return   3 ;
}

int  main()
{
    X
= 0 ;
    
while (cin >> n && getchar())
    {
       
if (n == 0 break ;
       X
++ ;
       
       
for ( long  i = 1 ;i <= n;i ++ )
         getline(cin,a[i]);
       cin
>> m;getchar();
       
for ( long  i = 1 ;i <= m;i ++ )
         getline(cin,b[i]);
       
//   Input
       
       cout
<< " Run # " << X << " " ;
       
long  result = judge();
       
if (result == 1 )
         cout
<< " Accepted " << endl;
       
else   if (result == 2 )
         cout
<< " Presentation Error " << endl;
       
else  cout << " Wrong Answer " << endl;
    }
return   0 ;
}

你可能感兴趣的:(UVa 10188 Automated Judge Script)