BUCT OJ 1702 压缩代码




#include <iostream>
#include <algorithm>
using namespace std;
int main()
	char ch;
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	while(scanf("%c", &ch) != EOF)
		if(ch == '\n')
			cout << "\\n";
		else if(ch == '"')
			cout << "\\\"";
		else if(ch == '\\')
			cout << "\\";
			cout << ch;
char str1[1000000]=
{"Network Working Group                                          J. Postel\nRequest for Comments: 959                                    J. Reynolds\n                                                                     ISI\nObsoletes RFC: 765 (IEN 149)                                October 1985\n\n                      FILE TRANSFER PROTOCOL (FTP)\n\n\nStatus of this Memo\n\n   This memo is the official specification of the File Transfer\n   Protocol (FTP).  Distribution of this memo is unlimited.\n\n   The following new optional commands are included in this edition of\n   the specification:\n\n      CDUP (Change to Parent Directory), SMNT (Structure Mount), STOU\n      (Store Unique), RMD (Remove Directory), MKD (Make Directory), PWD\n      (Print Directory), and SYST (System).\n\n   Note that this specification is compatible with the previous edition.\n\n1.  INTRODUCTION\n\n   The objectives of FTP are 1) to promote sharing of files (computer\n   programs and/or data), 2) to encourage indirect or implicit (via\n   programs) use of remote computers, 3) to shield a user from\n   variations in file storage systems among hosts, and 4) to transfer\n   data reliably and efficiently.  FTP, though usable directly by a user\n   at a terminal, is designed mainly for use by programs.\n\n   The attempt in this specification is to satisfy the diverse needs of\n   users of maxi-hosts, mini-hosts, personal workstations, and TACs,\n   with a simple, "};
char str2[1000000]=
{"and easily implemented protocol design.\n\n   This paper assumes knowledge of the Transmission Control Protocol\n   (TCP) [2] and the Telnet Protocol [3].  These documents are contained\n   in the ARPA-Internet protocol handbook [1].\n\n2.  OVERVIEW\n\n   In this section, the history, the terminology, and the FTP model are\n   discussed.  The terms defined in this section are only those that\n   have special significance in FTP.  Some of the terminology is very\n   specific to the FTP model; some readers may wish to turn to the\n   section on the FTP model while reviewing the terminology.\n\n\n\n\n\n\n\nPostel & Reynolds                                               [Page 1]\n\n\nRFC 959                                                     October 1985\nFile Transfer Protocol\n\n\n   2.1.  HISTORY\n\n      FTP has had a long evolution over the years.  Appendix III is a\n      chronological compilation of Request for Comments documents\n      relating to FTP.  These include the first proposed file transfer\n      mechanisms in 1971 that were developed for implementation on hosts\n      at M.I.T. (RFC 114), plus comments and discussion in RFC 141.\n\n      RFC 172 provided a user-level oriented protocol for file transfer\n      between host computers (including terminal IMPs).  A revision of\n      this as RFC 265, restated FTP for additional review, while RFC 281\n      suggested further changes.  The use of a \"Set Data Type\"\n      "};
char str3[1000000]=
{"transaction was proposed in RFC 294 in January 1982.\n\n      RFC 354 obsoleted RFCs 264 and 265.  The File Transfer Protocol\n      was now defined as a protocol for file transfer between HOSTs on\n      the ARPANET, with the primary function of FTP defined as\n      transfering files efficiently and reliably among hosts and\n      allowing the convenient use of remote file storage capabilities.\n      RFC 385 further commented on errors, emphasis points, and\n      additions to the protocol, while RFC 414 provided a status report\n      on the working server and user FTPs.  RFC 430, issued in 1973,\n      (among other RFCs too numerous to mention) presented further\n      comments on FTP.  Finally, an \"official\" FTP document was\n      published as RFC 454.\n\n      By July 1973, considerable changes from the last versions of FTP\n      were made, but the general structure remained the same.  RFC 542\n      was published as a new \"official\" specification to reflect these\n      changes.  However, many implementations based on the older\n      specification were not updated.\n\n      In 1974, RFCs 607 and 614 continued comments on FTP.  RFC 624\n      proposed further design changes and minor modifications.  In 1975,\n      RFC 686 entitled, \"Leaving Well Enough Alone\", discussed the\n      differences between all of the early and later versions of FTP.\n      RFC 691 presented a minor revision of RFC 686, "};
char str4[1000000]=
{"regarding the\n      subject of print files.\n\n      Motivated by the transition from the NCP to the TCP as the\n      underlying protocol, a phoenix was born out of all of the above\n      efforts in RFC 765 as the specification of FTP for use on TCP.\n\n      This current edition of the FTP specification is intended to\n      correct some minor documentation errors, to improve the\n      explanation of some protocol features, and to add some new\n      optional commands.\n\n\nPostel & Reynolds                                               [Page 2]\n\n\nRFC 959                                                     October 1985\nFile Transfer Protocol\n\n\n      In particular, the following new optional commands are included in\n      this edition of the specification:\n\n         CDUP - Change to Parent Directory\n\n         SMNT - Structure Mount\n\n         STOU - Store Unique\n\n         RMD - Remove Directory\n\n         MKD - Make Directory\n\n         PWD - Print Directory\n\n         SYST - System\n\n      This specification is compatible with the previous edition.  A\n      program implemented in conformance to the previous specification\n      should automatically be in conformance to this specification.\n\n   2.2.  TERMINOLOGY\n\n      ASCII\n\n         The ASCII character set is as defined in the ARPA-Internet\n         Protocol Handbook.  In FTP, ASCII characters are defined to be\n         the lower half of an "};
char str5[1000000]=
{"eight-bit code set (i.e., the most\n         significant bit is zero).\n\n      access controls\n\n         Access controls define users' access privileges to the use of a\n         system, and to the files in that system.  Access controls are\n         necessary to prevent unauthorized or accidental use of files.\n         It is the prerogative of a server-FTP process to invoke access\n         controls.\n\n      byte size\n\n         There are two byte sizes of interest in FTP:  the logical byte\n         size of the file, and the transfer byte size used for the\n         transmission of the data.  The transfer byte size is always 8\n         bits.  The transfer byte size is not necessarily the byte size\n         in which data is to be stored in a system, nor the logical byte\n         size for interpretation of the structure of the data.\n\n\n\nPostel & Reynolds                                               [Page 3]\n\n\nRFC 959                                                     October 1985\nFile Transfer Protocol\n\n\n      control connection\n\n         The communication path between the USER-PI and SERVER-PI for\n         the exchange of commands and replies.  This connection follows\n         the Telnet Protocol.\n\n      data connection\n\n         A full duplex connection over which data is transferred, in a\n         specified mode and type. The data transferred may be a part of\n         a file, "};
char str6[1000000]=
{"an entire file or a number of files.  The path may be\n         between a server-DTP and a user-DTP, or between two\n         server-DTPs.\n\n      data port\n\n         The passive data transfer process \"listens\" on the data port\n         for a connection from the active transfer process in order to\n         open the data connection.\n\n      DTP\n\n         The data transfer process establishes and manages the data\n         connection.  The DTP can be passive or active.\n\n      End-of-Line\n\n         The end-of-line sequence defines the separation of printing\n         lines.  The sequence is Carriage Return, followed by Line Feed.\n\n      EOF\n\n         The end-of-file condition that defines the end of a file being\n         transferred.\n\n      EOR\n\n         The end-of-record condition that defines the end of a record\n         being transferred.\n\n      error recovery\n\n         A procedure that allows a user to recover from certain errors\n         such as failure of either host system or transfer process.  In\n         FTP, error recovery may involve restarting a file transfer at a\n         given checkpoint.\n\n\n\nPostel & Reynolds                                               [Page 4]\n\n\nRFC 959                                                     October 1985\nFile Transfer Protocol\n\n\n      FTP commands\n\n         A set of commands that comprise the control information flowing\n         from the user-FTP to the server-FTP "};
char str7[1000000]=
{"process.\n\n      file\n\n         An ordered set of computer data (including programs), of\n         arbitrary length, uniquely identified by a pathname.\n\n      mode\n\n         The mode in which data is to be transferred via the data\n         connection.  The mode defines the data format during transfer\n         including EOR and EOF.  The transfer modes defined in FTP are\n         described in the Section on Transmission Modes.\n\n      NVT\n\n         The Network Virtual Terminal as defined in the Telnet Protocol.\n\n      NVFS\n\n         The Network Virtual File System.  A concept which defines a\n         standard network file system with standard commands and\n         pathname conventions.\n\n      page\n\n         A file may be structured as a set of independent parts called\n         pages.  FTP supports the transmission of discontinuous files as\n         independent indexed pages.\n\n      pathname\n\n         Pathname is defined to be the character string which must be\n         input to a file system by a user in order to identify a file.\n         Pathname normally contains device and/or directory names, and\n         file name specification.  FTP does not yet specify a standard\n         pathname convention.  Each user must follow the file naming\n         conventions of the file systems involved in the transfer.\n\n      PI\n\n         The protocol interpreter.  The user and server sides of the\n         protocol have distinct roles implemented in a user-PI and a\n         server-PI.\n\n\nPostel & Reynolds                                               [Page 5]\n\n\nRFC 959                                                     October 1985\nFile Transfer Protocol\n\n\n      record\n\n         A sequential file may be structured as a number of contiguous\n         parts called records.  Record structures are supported by FTP\n         but a file need not have record structure.\n\n      reply\n\n         A reply is an acknowledgment (positive or negative) sent from\n         server to user via the control connection in response to FTP\n         commands.  The general form of a reply is a completion code\n         (including error codes) followed by a text string.  The codes\n         are for use by programs and the text is usually intended for\n         human users.\n\n      server-DTP\n\n         The data transfer process, in its normal \"active\" state,\n         establishes the data connection with the \"listening\" data port.\n         It sets up parameters for transfer and storage, and transfers\n         data on command from its PI.  The DTP can be placed in a\n         \"passive\" state to listen for, rather than initiate a\n         connection on the data port.\n\n      server-FTP process\n\n         A process or set of processes which perform the function of\n         file transfer in cooperation with a user-FTP process and,\n         possibly, another server.  The functions consist of a protocol\n         interpreter (PI) and a data transfer process (DTP).\n\n      server-PI\n\n         The server protocol interpreter \"listens\" on Port L for a\n         connection from a user-PI and establishes a control\n         communication connection.  It receives standard FTP commands\n         from the user-PI, sends replies, and governs the server-DTP.\n\n      type\n\n         The data representation type used for data transfer and\n         storage.  Type implies certain transformations between the time\n         of data storage and data transfer.  The representation types\n         defined in FTP are described in the Section on Establishing\n         Data Connections.\n\n\n\n\nPostel & Reynolds                                               [Page 6]\n\n\nRFC 959                               "};
char str8[1000000]=
{"                      October 1985\nFile Transfer Protocol\n\n\n      user\n\n         A person or a process on behalf of a person wishing to obtain\n         file transfer service.  The human user may interact directly\n         with a server-FTP process, but use of a user-FTP process is\n         preferred since the protocol design is weighted towards\n         automata.\n\n      user-DTP\n\n         The data transfer process \"listens\" on the data port for a\n         connection from a server-FTP process.  If two servers are\n         transferring data between them, the user-DTP is inactive.\n\n      user-FTP process\n\n         A set of functions including a protocol interpreter, a data\n         transfer process and a user interface which together perform\n         the function of file transfer in cooperation with one or more\n         server-FTP processes.  The user interface allows a local\n         language to be used in the command-reply dialogue with the\n         user.\n\n      user-PI\n\n         The user protocol interpreter initiates the control connection\n         from its port U to the server-FTP process, initiates FTP\n         commands, and governs the user-DTP if that process is part of\n         the file transfer.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nPostel & Reynolds                                               [Page 7]\n\n\n                                                                        \nRFC 959                                                     October 1985\nFile Transfer Protocol\n\n\n   2.3.  THE FTP MODEL\n\n      With the above definitions in mind, the following model (shown in\n      Figure 1) may be diagrammed for an FTP service.\n\n                                            -------------\n                                            |/---------\\|\n                                            ||   User  ||    --------\n                                            ||Interface|<--->| User |\n                                            |\\----^----/|    --------\n                  ----------                |     |     |\n                  |/------\\|  FTP Commands  |/----V----\\|\n                  ||Server|<---------------->|   User  ||\n                  ||  PI  ||   FTP Replies  ||    PI   ||\n                  |\\--^---/|                |\\----^----/|\n                  |   |    |                |     |     |\n      --------    |/--V---\\|      Data      |/----V----\\|    --------\n      | File |<--->|Server|<---------------->|  User   |<--->| File |\n      |System|    || DTP  ||   Connection   ||   DTP   ||    |System|\n      --------    |\\------/|                |\\---------/|    --------\n                  ----------                -------------\n\n                  Server-FTP                   USER-FTP\n\n      NOTES: 1. The data connection may be used in either direction.\n             2. The data connection need not exist all of the time.\n\n                      Figure 1  Model for FTP Use\n\n      In the model described in Figure 1, the user-protocol interpreter\n      initiates the control connection.  The control connection follows\n      the Telnet protocol.  At the initiation of the user, standard FTP\n      commands are generated by the user-PI and transmitted to the\n      server process via the control connection.  (The user may\n      establish a direct control connection to the server-FTP, from a\n      TAC terminal for example, and generate standard FTP commands\n      independently, bypassing the user-FTP process.) Standard replies\n      are sent from the server-PI to the user-PI over the control\n      connection in response to the commands.\n\n      The FTP commands specify the parameters for the data connection\n      (data port, transfer mode, representation type, and structure) and\n      the nature of file system operation (store, retrieve, append,\n      delete, etc.).  The user-DTP or its designate should \"listen\" on\n      the specified data port, and the server initiate the data\n      connection and data transfer in accordance with the specified\n      parameters.  It should be noted that the data port need not be in\n\n\nPostel & Reynolds                                               [Page 8]\n\n\n                                                                        \nRFC 959                                                     October 1985\nFile Transfer Protocol\n\n\n      the same host that initiates the FTP commands via the control\n      connection, but the user or the user-FTP process must ensure a\n      \"listen\" on the specified data port.  It ought to also be noted\n      that the data connection may be used for simultaneous sending and\n      receiving.\n\n      In another situation a user might wish to transfer files between\n      two hosts, neither of which is a local host. The user sets up\n      control connections to the two servers and then arranges for a\n      data connection between them.  In this manner, control information\n      is passed to the user-PI but data is transferred between the\n      server data transfer processes.  Following is a model of this\n      server-server interaction.\n\n      \n                    Control     ------------   Control\n                    ---------->| User-FTP |<-----------\n                    |          | User-PI  |           |\n                    |          |   \"C\"    |           |\n                    V          ------------           V\n            --------------                        --------------\n            | Server-FTP |   Data Connection      | Server-FTP |\n            |    \"A\"     |<---------------------->|    \"B\"     |\n            -------------- Port (A)      Port (B) --------------\n      \n\n                                 Figure 2\n\n      The protocol requires that the control connections be open while\n      data transfer is in progress.  It is the responsibility of the\n      user to request the closing of the control connections when\n      finished using the FTP service, while it is the server who takes\n      the action.  The server may abort data transfer if the control\n      connections are "};
char str9[1000000]=
{"closed without command.\n\n      The Relationship between FTP and Telnet:\n\n         The FTP uses the Telnet protocol on the control connection.\n         This can be achieved in two ways: first, the user-PI or the\n         server-PI may implement the rules of the Telnet Protocol\n         directly in their own procedures; or, second, the user-PI or\n         the server-PI may make use of the existing Telnet module in the\n         system.\n\n         Ease of implementaion, sharing code, and modular programming\n         argue for the second approach.  Efficiency and independence\n\n\n\nPostel & Reynolds                                               [Page 9]\n\n\nRFC 959                                                     October 1985\nFile Transfer Protocol\n\n\n         argue for the first approach.  In practice, FTP relies on very\n         little of the Telnet Protocol, so the first approach does not\n         necessarily involve a large amount of code.\n\n\n\nPostel & Reynolds                                              [Page 10]\n"};
int main()
	//freopen("output1.txt", "w", stdout);
	cout << str1 << str2 << str3 << str4 << str5 << str6 << str7 << str8 << str9 << endl;


Tanky Woo

Tanky Woo,[个人主页:https://tankywoo.com] / [新博客:https://blog.tankywoo.com]

《BUCT OJ 1702 压缩代码》有4个想法


电子邮件地址不会被公开。 必填项已用*标注