題意:
(from luckycat)
解法: 字串處理。
TAG: ad hoc
注意:
程式碼:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Tittle: 10188 - Automated Judge Script | |
* Author: Cheng-Shih, Wong | |
* Date: 2015/05/09 | |
*/ | |
// include files | |
#include <iostream> | |
#include <cstdio> | |
#include <cstring> | |
using namespace std; | |
// definitions | |
#define FOR(i,a,b) for( int i=(a),_n=(b); i<=_n; ++i ) | |
#define clr(x,v) memset( x, v, sizeof(x) ) | |
#define N 20005 | |
// declarations | |
int ti = 1; | |
int n, m; | |
char buf[N], ans[N], test[N]; | |
// functions | |
bool isDig( char ch ) | |
{ | |
return ('0'<=ch && ch<='9'); | |
} | |
bool judge( char *s, char *t ) | |
{ | |
// printf( "(%s) (%s)\n", s, t ); | |
while( true ) { | |
while( *s && !isDig(*s) ) ++s; | |
while( *t && !isDig(*t) ) ++t; | |
if( !(*s) && !(*t) ) return true; | |
if( !(*s) || !(*t) ) return false; | |
if( *s != *t ) return false; | |
++s; ++t; | |
} | |
} | |
// main function | |
int main( void ) | |
{ | |
// input | |
while( scanf( "%d", &n )==1 && n ) { | |
gets(buf); | |
gets(ans); | |
FOR( i, 1, n-1 ) { | |
gets(buf); | |
strcat( ans, "\n" ); | |
strcat( ans, buf ); | |
} | |
scanf( "%d", &m ); | |
gets(buf); | |
gets(test); | |
FOR( i, 1, m-1 ) { | |
gets(buf); | |
strcat( test, "\n" ); | |
strcat( test, buf ); | |
} | |
// solve & output | |
printf( "Run #%d: ", ti++ ); | |
if( !strcmp(ans,test) ) { | |
puts("Accepted"); | |
} else if( judge(ans,test) ) { | |
puts("Presentation Error"); | |
} else { | |
puts("Wrong Answer"); | |
} | |
} | |
return 0; | |
} |
沒有留言:
張貼留言
任何意見都樂意傾聽