Logo
(追記) (追記ここまで)

6731번 - Comment removal 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB111100.000%

문제

Given an arbitrary, syntactically correct Pascal program, you are to compress it. (Note that you do not have to know the programming language Pascal to solve this problem; all relevant information is given below.) Here are the guidelines describing how to compress the program:

  • Replace all sequences of blanks, except those within a string constant, with a single blank. Also, remove all blanks at the beginning of a line and all blanks at the end of a line.
    In Pascal, strings are delimited by single quotes (“’”). Inside a string, two consecutive single quotes denote a single quote character. Examples are
    ’this is a string’
    ’isn’’t this fun?’

    Strings may not cross line boundries.
  • Replace all comments with a single space. (If this space comes next to another space, the two are compressed as described above.)
    In Pascal, comments are enclosed by either “(* · · · *)” or “{ · · · }”, as in
    (* This is a comment! *)
    { A comment with a ‘*)’. }
    (* A (* comment *)

    Comments may span several lines. They may not be nested.
  • Eliminate totally blank lines, i.e., lines that contain only spaces (initially, or after comment removel).
  • You can assume that the source contains no TABs or other non-printing characters (except, of course, line separators).
  • You can assume that no source text line is longer than 255 characters.

입력

The input file contains a syntactically correct Pascal program, like this:

{_The_famous_’Hello_world’_program_}
program__Hello__(output);
__(*_no_declarations_*)
begin
__WriteLn(’Hello_,__’’quaint’’__world_!’);
end.

(Note that space characters are shown as “_” to make them easier to spot.)

출력

The output should be a compressed Pascal program. For example, the program shown above should be reduced to

program_Hello_(output);
begin
WriteLn(’Hello_,__’’quaint’’__world_!’); 
end.

제한

예제 입력 1

{ The famous 'Hello world' program }
program Hello (output):
 (* no declarations *)
begin
 WriteLn('Hello , ''quaint'' world !');
end.

예제 출력 1

program Hello (output):
begin
WriteLn('Hello , ''quaint'' world !');
end.

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Nordic Collegiate Programming Contest > NCPC 2000 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /