Not a difficult problem. just catenate the lines together and compare the correct and submitted answer will do it well. unfortunately, the problem statement is misleading: I get wa consistently with a "linesize" of 102, however, it becomes AC when I switch to 110.
Code:
- /*************************************** **********************************
- * Copyright (c) 2008 by liukaipeng *
- * Liukaipeng at gmail dot com *
- **************************************** *********************************/
- /* @ Judge_id 00000 10188 C ++ "Automated judge script "*/
- # Include <cstdlib>
- # Include <iostream>
- # Include <fstream>
- # Include <string>
- # Include <vector>
- Using namespace STD;
- Int const linecount = 100;
- Int const linesize = 110;
- Int judge (char * correct, int ncorrect, char * submit, int nsubmit)
- {
- Int result = 0;
- If (ncorrect! = Nsubmit ){
- Result = 1;
- }
- Int p = 0;
- If (result = 0 ){
- For (; correct [p]! = '/0' | submit [p]! = '/0'; ++ p ){
- If (correct [p]! = Submit [p]) {
- Result = 1;
- Break;
- }
- }
- }
- Int c = P, S = P;
- If (result = 1 ){
- For (; correct [c]! = '/0' | submit [s]! = '/0 ';){
- For (; correct [c]! = '/0 '&&! Isdigit (correct [c]); ++ c ){}
- For (; submit [s]! = '/0 '&&! Isdigit (submit [s]); ++ s ){}
- If (correct [C ++]! = Submit [s ++]) {
- Result = 2;
- Break;
- }
- }
- }
- Return result;
- }
- Int main (INT argc, char * argv [])
- {
- # Ifndef online_judge
- Filebuf In, out;
- Cin. rdbuf (in. Open (string (argv [0]) + ". In"). c_str (), ios_base: In ));
- Cout. rdbuf (out. Open (string (argv [0]) + ". Out"). c_str (), ios_base: Out ));
- # Endif
- Char const * Results [] = {
- "Accepted ",
- "Presentation error ",
- "Wrong answer ",
- };
- For (INT run = 1; ++ run ){
- Char Buf [10];
- Cin. Getline (BUF, 10 );
- Int ncorrect = atoi (BUF );
- If (0 = ncorrect ){
- Break;
- }
- Char correct [linecount * linesize] = {0 };
- For (INT I = 0, Pos = 0; I <ncorrect; ++ I, POS + = cin. gcount ()-1 ){
- Cin. Getline (correct + POs, linesize );
- }
- Cin. Getline (BUF, 10 );
- Int nsubmit = atoi (BUF );
- Char submit [linecount * linesize] = {0 };
- For (INT I = 0, Pos = 0; I <nsubmit; ++ I, POS + = cin. gcount ()-1 ){
- Cin. Getline (submit + POs, linesize );
- }
- Int result = judge (correct, ncorrect, submit, nsubmit );
- Cout <"run #" <run <":" <Results [Result] <"/N ";
- }
- Return 0;
- }