This is a partial judge problem Owo.
You're asked to implement several Codec that inherit the BaseCodec.
class BaseCodec { public: virtual ~BaseCodec() {} virtual std::string encode(const std::string&) = 0; };
There are three types of Codec.
The first one is the Reverse Codec, it should reverse the entire string.
The second one is the Compress Codec, it should replace the consecutive and repeated part with the count of the repeated part and a single instance of that character. Note that if the count is either 1 or 2, the length won't decrease after encoding, so you don't have to deal with the part that the count of the consecutive and repeated characters is either 1 or 2.
The third one is the Delay Codec, it should return the previous string that the user asked to encode. The first encoding request must return "None".
BaseCodec* getCodec(const std::string& name);
For the above function, you have to return the Codec Object according to the parameter name. The name of the Codec are "Reverse", "Compress" and "Delay", respectively.
For more information, you should refer to the main.cpp and function.h.
The first line of the input contains a single integer N representing the number of Codec.
For the next N lines, each line contains a string, representing the type of the Codec from 0 to n - 1.
Next line contains a single integer Q representing the number of times of Encoding.
For the next Q lines, each line contains an integer representing the index of Codec and a string to do encoding on that Codec.
Constraint of testcases:
Testcase 1: Identical to the sample input.
Testcase 2 ~ 4: Contains only Reverse Codec.
Testcaes 5 ~ 7: Contains only Reverse Codec and Compress Codec.
Testcaes 8 ~ 10: Contains all three types of Codec.
Guarantee the string that use Reverse/Delay Codec contains only uppercase, lowercase alphabets and 0 ~ 9, and the string that use Compress Codec contains only uppercase and lowercase alphabets.
For each time of Encoding, output the string after encoding.