ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

NEERC, Central subregion, Rybinsk, October 2002

About     Problems     Submit solution     Judge status     Standings
Contest is over

G. Introspective Program

Time limit: 1.0 second
Memory limit: 64 MB
There is probably no programmer that had not heard of a famous problem set by Norbert Wiener. The problem is to write a program that, being run, sends its source code to the output device. Note, that it is not allowed to use the files containing the source code, or system-dependent features (e.g. knowing the address of a memory area that could possibly contain the source code). Such a program is called an introspective one. A theorem is well known, which states that it is possible to write an introspective program in almost any programming language.
It would be unfair to demand writing an introspective program in a language known to a different degree by different participants. Therefore we describe a formal syntax for a new language called PIBAS. And your task is to write a program that writes an introspective PIBAS program to the output.
Testing this PIBAS program includes a syntax check and a test run. A program is considered correct if it outputs a string equal to its source code.
PIBAS description:
  1. A PIBAS program consists of one or more operators separated with ";" (semicolon). A program is written in one line that is no longer than 32000 characters.
  2. Two types of operators exist: string assignment operator and output operator.
  3. Assignment operator is used as follows: <String variable>=<String expression>
  4. String variable is denoted with a single capital Latin letter.
  5. String expression is either a string variable, or a string constant, or a substring function, or a concatenation of string expressions with the use of "+" (plus) character.
  6. String constant is a sequence of any printable characters enclosed in double (") or single (') quotes. This sequence cannot contain the quote character it is enclosed in. Examples: 'Rybinsk', "O key!", "I don't know solution."
  7. A substring function is used in the following way: $(<string variable>,<unsigned integer>,<unsigned integer>). The second parameter sets the starting character of the substring and the third one sets its length. Character numeration is one-based.
  8. Output operator: ?<string expression>.
The total length of all strings sent to output may not exceed 32000 characters.
PIBAS program Output
?"Hello, "+'World!' Hello, World!
A='World, Hello!';?$(A,8,5);?", ";B=$(A,1,5)+'!';?B Hello, World!


Input is not used.


The output must contain an introspective PIBAS program.
Problem Source: 2002-2003 ACM Central Region of Russia Quarterfinal Programming Contest, Rybinsk, October 2002
To submit the solution for this problem go to the Problem set: 1230. Introspective Program