Ultraviolet A Problem Solution: 10188-automated judge script

Source: Internet
Author: User

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:

  1. /*************************************** **********************************
  2. * Copyright (c) 2008 by liukaipeng *
  3. * Liukaipeng at gmail dot com *
  4. **************************************** *********************************/
  5. /* @ Judge_id 00000 10188 C ++ "Automated judge script "*/
  6. # Include <cstdlib>
  7. # Include <iostream>
  8. # Include <fstream>
  9. # Include <string>
  10. # Include <vector>
  11. Using namespace STD;
  12. Int const linecount = 100;
  13. Int const linesize = 110;
  14. Int judge (char * correct, int ncorrect, char * submit, int nsubmit)
  15. {
  16. Int result = 0;
  17. If (ncorrect! = Nsubmit ){
  18. Result = 1;
  19. }
  20. Int p = 0;
  21. If (result = 0 ){
  22. For (; correct [p]! = '/0' | submit [p]! = '/0'; ++ p ){
  23. If (correct [p]! = Submit [p]) {
  24. Result = 1;
  25. Break;
  26. }
  27. }
  28. }
  29. Int c = P, S = P;
  30. If (result = 1 ){
  31. For (; correct [c]! = '/0' | submit [s]! = '/0 ';){
  32. For (; correct [c]! = '/0 '&&! Isdigit (correct [c]); ++ c ){}
  33. For (; submit [s]! = '/0 '&&! Isdigit (submit [s]); ++ s ){}
  34. If (correct [C ++]! = Submit [s ++]) {
  35. Result = 2;
  36. Break;
  37. }
  38. }
  39. }
  40. Return result;
  41. }
  42. Int main (INT argc, char * argv [])
  43. {
  44. # Ifndef online_judge
  45. Filebuf In, out;
  46. Cin. rdbuf (in. Open (string (argv [0]) + ". In"). c_str (), ios_base: In ));
  47. Cout. rdbuf (out. Open (string (argv [0]) + ". Out"). c_str (), ios_base: Out ));
  48. # Endif
  49. Char const * Results [] = {
  50. "Accepted ",
  51. "Presentation error ",
  52. "Wrong answer ",
  53. };
  54. For (INT run = 1; ++ run ){
  55. Char Buf [10];
  56. Cin. Getline (BUF, 10 );
  57. Int ncorrect = atoi (BUF );
  58. If (0 = ncorrect ){
  59. Break;
  60. }
  61. Char correct [linecount * linesize] = {0 };
  62. For (INT I = 0, Pos = 0; I <ncorrect; ++ I, POS + = cin. gcount ()-1 ){
  63. Cin. Getline (correct + POs, linesize );
  64. }
  65. Cin. Getline (BUF, 10 );
  66. Int nsubmit = atoi (BUF );
  67. Char submit [linecount * linesize] = {0 };
  68. For (INT I = 0, Pos = 0; I <nsubmit; ++ I, POS + = cin. gcount ()-1 ){
  69. Cin. Getline (submit + POs, linesize );
  70. }
  71. Int result = judge (correct, ncorrect, submit, nsubmit );
  72. Cout <"run #" <run <":" <Results [Result] <"/N ";
  73. }
  74. Return 0;
  75. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.