제출 #235936

#제출 시각아이디문제언어결과실행 시간메모리
235936laricasota콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
unit combo_lib; interface function press(p: ansistring): longint; implementation uses combo; const MAX_NUM_MOVES: longint = 8000; var N: longint; S: ansistring; num_moves: longint; procedure wrong_answer(MSG: ansistring); begin writeln('Wrong Answer: ', MSG); halt(0); end; function press(p: ansistring): longint; var len, coins, i, j: longint; begin num_moves += 1; if num_moves > MAX_NUM_MOVES then begin wrong_answer('too many moves'); end; len := length(p); if len > 4 * N then begin wrong_answer('invalid press'); end; for i := 1 to len do begin if (p[i] <> 'A') and (p[i] <> 'B') and (p[i] <> 'X') and (p[i] <> 'Y') then begin wrong_answer('invalid press'); end; end; coins := 0; j := 0; for i := 1 to len do begin if (j + 1 <= N) and (S[j + 1] = p[i]) then begin j += 1; end else if S[1] = p[i] then begin j := 1; end else begin j := 0; end; if coins < j then begin coins := j; end; end; exit(coins); end; var answer: ansistring; begin if eof then begin writeln(stderr, 'Error while reading input'); halt(1); end; {$I-} read(S); {$I+} if ioresult <> 0 then begin writeln(stderr, 'Error while reading input'); halt(1); end; N := length(S); num_moves := 0; answer := guess_sequence(N); if answer <> S then begin wrong_answer('wrong guess'); end; writeln('Accepted: ', num_moves); end.

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp:21:11: warning: character constant too long for its type
   21 |   writeln('Wrong Answer: ', MSG);
      |           ^~~~~~~~~~~~~~~~
combo.cpp:31:18: warning: character constant too long for its type
   31 |     wrong_answer('too many moves');
      |                  ^~~~~~~~~~~~~~~~
combo.cpp:35:18: warning: character constant too long for its type
   35 |     wrong_answer('invalid press');
      |                  ^~~~~~~~~~~~~~~
combo.cpp:39:20: warning: character constant too long for its type
   39 |       wrong_answer('invalid press');
      |                    ^~~~~~~~~~~~~~~
combo.cpp:63:21: warning: character constant too long for its type
   63 |     writeln(stderr, 'Error while reading input');
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
combo.cpp:70:21: warning: character constant too long for its type
   70 |     writeln(stderr, 'Error while reading input');
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
combo.cpp:78:18: warning: character constant too long for its type
   78 |     wrong_answer('wrong guess');
      |                  ^~~~~~~~~~~~~
combo.cpp:80:11: warning: character constant too long for its type
   80 |   writeln('Accepted: ', num_moves);
      |           ^~~~~~~~~~~~
combo.cpp:1:1: error: 'unit' does not name a type
    1 | unit combo_lib;
      | ^~~~
combo.cpp:3:1: error: 'interface' does not name a type
    3 | interface
      | ^~~~~~~~~
combo.cpp:7:1: error: 'implementation' does not name a type
    7 | implementation
      | ^~~~~~~~~~~~~~
combo.cpp:12:16: error: found ':' in nested-name-specifier, expected '::'
   12 |   MAX_NUM_MOVES: longint = 8000;
      |                ^
      |                ::
combo.cpp:12:3: error: 'MAX_NUM_MOVES' does not name a type
   12 |   MAX_NUM_MOVES: longint = 8000;
      |   ^~~~~~~~~~~~~
combo.cpp:14:1: error: 'var' does not name a type
   14 | var
      | ^~~
combo.cpp:16:4: error: found ':' in nested-name-specifier, expected '::'
   16 |   S: ansistring;
      |    ^
      |    ::
combo.cpp:16:3: error: 'S' does not name a type
   16 |   S: ansistring;
      |   ^
combo.cpp:17:12: error: found ':' in nested-name-specifier, expected '::'
   17 |   num_moves: longint;
      |            ^
      |            ::
combo.cpp:17:3: error: 'num_moves' does not name a type
   17 |   num_moves: longint;
      |   ^~~~~~~~~
combo.cpp:19:1: error: 'procedure' does not name a type
   19 | procedure wrong_answer(MSG: ansistring);
      | ^~~~~~~~~
combo.cpp:20:1: error: 'begin' does not name a type
   20 | begin
      | ^~~~~
combo.cpp:22:7: error: expected constructor, destructor, or type conversion before '(' token
   22 |   halt(0);
      |       ^
combo.cpp:23:1: error: 'end' does not name a type
   23 | end;
      | ^~~
combo.cpp:25:1: error: 'function' does not name a type; did you mean 'union'?
   25 | function press(p: ansistring): longint;
      | ^~~~~~~~
      | union
combo.cpp:26:1: error: 'var' does not name a type
   26 | var
      | ^~~
combo.cpp:28:1: error: 'begin' does not name a type
   28 | begin
      | ^~~~~
combo.cpp:30:3: error: expected unqualified-id before 'if'
   30 |   if num_moves > MAX_NUM_MOVES then begin
      |   ^~
combo.cpp:32:3: error: 'end' does not name a type
   32 |   end;
      |   ^~~
combo.cpp:33:3: error: 'len' does not name a type
   33 |   len := length(p);
      |   ^~~
combo.cpp:34:3: error: expected unqualified-id before 'if'
   34 |   if len > 4 * N then begin
      |   ^~
combo.cpp:36:3: error: 'end' does not name a type
   36 |   end;
      |   ^~~
combo.cpp:37:3: error: expected unqualified-id before 'for'
   37 |   for i := 1 to len do begin
      |   ^~~
combo.cpp:40:5: error: 'end' does not name a type
   40 |     end;
      |     ^~~
combo.cpp:41:3: error: 'end' does not name a type
   41 |   end;
      |   ^~~
combo.cpp:42:3: error: 'coins' does not name a type
   42 |   coins := 0;
      |   ^~~~~
combo.cpp:43:3: error: 'j' does not name a type
   43 |   j := 0;
      |   ^
combo.cpp:44:3: error: expected unqualified-id before 'for'
   44 |   for i := 1 to len do begin
      |   ^~~
combo.cpp:47:5: error: 'end' does not name a type
   47 |     end else if S[1] = p[i] then begin
      |     ^~~
combo.cpp:49:5: error: 'end' does not name a type
   49 |     end else begin
      |     ^~~
combo.cpp:51:5: error: 'end' does not name a type
   51 |     end;
      |     ^~~
combo.cpp:52:5: error: expected unqualified-id before 'if'
   52 |     if coins < j then begin
      |     ^~
combo.cpp:54:5: error: 'end' does not name a type
   54 |     end;
      |     ^~~
combo.cpp:55:3: error: 'end' does not name a type
   55 |   end;
      |   ^~~
combo.cpp:56:7: error: expected constructor, destructor, or type conversion before '(' token
   56 |   exit(coins);
      |       ^
combo.cpp:57:1: error: 'end' does not name a type
   57 | end;
      | ^~~
combo.cpp:59:1: error: 'var' does not name a type
   59 | var
      | ^~~
combo.cpp:61:1: error: 'begin' does not name a type
   61 | begin
      | ^~~~~
combo.cpp:64:9: error: expected constructor, destructor, or type conversion before '(' token
   64 |     halt(1);
      |         ^
combo.cpp:65:3: error: 'end' does not name a type
   65 |   end;
      |   ^~~
combo.cpp:66:3: error: expected unqualified-id before '{' token
   66 |   {$I-}
      |   ^
combo.cpp:67:7: error: expected constructor, destructor, or type conversion before '(' token
   67 |   read(S);
      |       ^
combo.cpp:68:3: error: expected unqualified-id before '{' token
   68 |   {$I+}
      |   ^
combo.cpp:69:3: error: expected unqualified-id before 'if'
   69 |   if ioresult <> 0 then begin
      |   ^~
combo.cpp:71:9: error: expected constructor, destructor, or type conversion before '(' token
   71 |     halt(1);
      |         ^
combo.cpp:72:3: error: 'end' does not name a type
   72 |   end;
      |   ^~~
combo.cpp:73:3: error: 'N' does not name a type
   73 |   N := length(S);
      |   ^
combo.cpp:75:3: error: 'num_moves' does not name a type
   75 |   num_moves := 0;
      |   ^~~~~~~~~
combo.cpp:76:3: error: 'answer' does not name a type
   76 |   answer := guess_sequence(N);
      |   ^~~~~~
combo.cpp:77:3: error: expected unqualified-id before 'if'
   77 |   if answer <> S then begin
      |   ^~
combo.cpp:79:3: error: 'end' does not name a type
   79 |   end;
      |   ^~~
combo.cpp:80:10: error: expected constructor, destructor, or type conversion before '(' token
   80 |   writeln('Accepted: ', num_moves);
      |          ^
combo.cpp:81:1: error: 'end' does not name a type
   81 | end.
      | ^~~